WTH: Why does going "back" from a modal sometimes close it and other times exits the app entirely?

Right after opening a modal in the android app, “back” closes the modal, as expected.

However, after going to another screen (e.g. going from an info modal, via a button on the home screen, for an automation to editing that automation from the dropdown), “back” then goes back to the modal then back a screen (or exits entirely if that’s not possible) instead of closing the modal.

This is an issue with how page navigstion is stored. This WTH has some more details: