There is much more to this issue than “rights.”
My Dad served in the British Army from 1939 to 1946 but was never assigned to any area when the allies were confronting the Germans. He served in North Africa (behind the battle lines), the middle east, Italy, and the far east. Why? His mother was from India and from her he inherited darkish skin and certain facial features. On top of that Grandma was from a Zoroastrian family, which meant Dad and his brothers were cirumcised. Like Jewish men are circumcised (the two religions are similar in many ways). And most people should be aware of what happened to Jewish men taken captive by the Nazis.
Fortunately there was plenty going on elsewhere and the army found plenty of useful work for Dad.
With that in mind, think what the ISIS brutes would have done to any soldier taken captive were they found to be transgender had the USA involved itself in actions on the ground. Officers are responsible for doing everything possible to ensure the safety of men under their command.