I did not research the problem to any depth, but to overcome a "blacklisted directory" said it all to me. I am not meant to access this directory.
To use FlatPak you have to use a non-standard (non-blacklisted) directory for all your installed libraries. Yeah right!
Unless a tool is provided (and documented) to update the internal FlatPak "/usr" directories then I would say FlatPak is not an option for almost all programmers.
Your post of your discussion on FlatPak was interesting, "... the IDE needs to understand its in a sandbox and run build commands in a different context (be it a different sandbox, or in this case escaping the sandbox on the host)."
Yeah right!
Regards AlanX