Thank you for the script!
I wish the Flatpak developers would start focusing on the little details to solve problems like this. I have been using Fedora Kinoite for a couple of years and it heavily depends on Flatpaks. It works well, but due to many problems like this, I no longer try to fix Flatpak issues. I always try Flatpaks first, but revert to layering native packages at the first problem. I just do not feel it is worth all of the workarounds.
I will try to remember to give this script a try the next time I do a fresh install before falling back to native packages.