This hack isn’t really workable as it clears out all the legit p and br tas.
This seems like an insanely easy fix for the WordPress team. Add a hidden field to the editor page that’s value changes when you click the HTML tab.
Then it would be easy to create filters that only work in a specific mode and this problem could be averted.
Please disregard this, it was a user error on my part. I mistakenly thought this function would return posts and pages, when it only returns posts.