Dealing with an UI element that is either hidden or displayed

I'm trying to make a macro for this purpose: when I press a floating button, it will tap a menu item with the id com.mixplorer:id/overflow The problem is that this overflow menu is either hidden or displayed (alongside other UI elements). Tapping the screen is like a switch to hide or show it.

How can I check if this menu is displayed on screen and if it's not, tap the screen once (make it appear)?

reddit.com
u/Fractal-Infinity — 23 days ago