If i remmember correctly, T5 Level 40 can't, but most T5 Level 50 can use the T5U, and some T5 Level 50 very rares like the Kazon Raider can take a T6X on top of that.
You have to upgrade T5's with the T5 Upgrade token before you apply the TX upgrade token.
"You don't want to patrol!? You don't want to escort!? You don't want to defend the Federation's Starbases!? Then why are you flying my Starships!? If you were a Klingon you'd be killed on the spot, but lucky for you.....you WERE in Starfleet. Let's see how New Zealand Penal Colony suits you." Adm A. Necheyev.
Some T5u ships come already upgraded to the "U" level (those already have the ship mastery track), some don't but come with the token for free, but most you still have to buy the U-upgrade token separately and use it before trying to apply the X-upgrade one (they have to be applied at the "manage ships" vendor).
Comments
It can get very confusing. The STO wiki has been a helpfull tool for many https://stowiki.net/wiki/Playable_starship
Edit; I just checked the wiki, i'm only partially correct. If in doubt, see the wiki.
https://sto.fandom.com/wiki/Starship_Upgrade_Requisition
Some T5u ships come already upgraded to the "U" level (those already have the ship mastery track), some don't but come with the token for free, but most you still have to buy the U-upgrade token separately and use it before trying to apply the X-upgrade one (they have to be applied at the "manage ships" vendor).