I had the same issue with Xcode and was finally able to fix it by following the steps below.
Select App Store Connect from the second window and Next
After that, the same error message will be displayed, but you will now be able to proceed to the next step.
Select the sign-in method for manual signing as shown below.
After completing all these steps, you can export a signed .ipa file.
Now, go to the App Store on your Mac and download the Transporter app. Log in to Transporter, then click the '+' icon at the top left corner and select the exported .ipa file. I hope you are able to upload the app to TestFlight without any issues.