I had the same issue and solved on the iPhone:
1- Delete the TestFlight App
2- Go to Settings and log out from the Media & Purchase Section (On iOS 17 you get there by clicking your name on the top of Setting App)
3- Download TestFlight again and it just showed the app so I could install it on the device.
4- Log in to Media & Purchases again (just to be able to use the App Store again on the device).