I have bough Xiaomi Pocophone F1 phone, just for testing my app.
If exclude my app from MI battery optimizer, notification has delay when phone go to doze mode, but notification is delivered.
If my app is not excluded from Mi battery saver, 50% of notification arrive, 50% are lost.
Standard battery optimizer cannot be found in phone from any menu in settings. Code from post #8 is only way to turn off system battery optimization for my app on Xiaomi phone.
Also I have an app with widget. Widget need to be updated every hour in exact time, for example 07:15h, 08:15h, 09:15h, etc. This won't work if app is not excluded from battery optimization.
Without exclusion, widget is updated 2-3 times a day, instead 24 times a day.