Is there a way to show OTP messages on screen without opening OTP messages?
Try Multi Clipboard and OTP Viewer. While this does Multi Copy or is a Clipboard manager, This also reads One time Passwords and show on a floating widget that actually resolves your issue.
Since you want to use OTP codes without switching to inbox, this app shows the OTP message in a floating widget and the code floats on screen as soon message arrives in your inbox.

Note: I'm affiliated with the company CV Infotech which has developed this app.