I don’t think a blanket veto on people with psychiatric conditions accessing gender reassignment treatment/surgery would stand up to legal challenge.
It stands up legally if having a particular psychiatric condition means that the treatment will make their condition worse. There are other treatments that are contra-indicated for certain psychiatric conditions - e.g. talk therapy is contra-indicated for some conditions (because it is harmful to the people who have them) and it's legal to refuse. Why would gender reassignment be different?
I have been party to many discussions where anxiety had been expressed about the potential ‘oppression’ of autistic people through denying them gender affirming treatment on the basis of being autistic. For many, it’s seen as a right!
Are those discussions with people who understand the law? People can think it's a "right" but that doesn't mean it legally is a right. People may believe they are being "oppressed" but self-decided "oppression" has nothing to do with the law or even whether they really are being oppressed. People in this country don't have a right to demand that doctors knowingly harm them. Refusal to harm someone is not oppression.