I'm fairly confident that it's a change in Flatpak itself rather than any one specific Flatpak, since all of my apps now use the same new screen sharing interface. Difference is that it actually works in those apps.
Were you using X11 before, by chance? IIRC Fedora 40 dropped X11, and only ships with Wayland by default. The fact that all of your apps are using the same screen sharing interface sounds like they're using the screen share portal due to running under a Wayland session, which Discord doesn't currently support currently.
For a while there was a workaround using a tool called XWaylandVideoBridge but even that stopped working for me.
I've heard that Vesktop supports screensharing under Wayland (and supposedly with sound support too), and it is available on Flathub - might be worth a try.