This is a case I’d heard about over 20 years ago, but I recently found the actual reference for it:
The arbitrariness of gender-based privilege in exercising priesthood is illustrated in one example from the late 1980s. A former missionary elder underwent medical tests and was discovered to possess the complete reproductive and sexual organs of a female beneath a superficial, non-functional male organ. She had surgery to restore femaleness. Her temple marriage was annulled. It was decided that her priesthood would not be revoked, but she was told she could not exercise it. It was also decided that the priesthood ordinances she performed on her mission, including several baptisms, confirmations, and blessings, would stand as valid ordinances. When she was presumed to be male, she was allowed to exercise priesthood. People accepted her authority, felt the spirit of God, and considered her administration of saving ordinances to be valid. Yet she had the reproductive organs of a woman, not a man.
One wonders if the Church at that period of time considered this to be a non-elective sex reassignment/gender confirmation surgery.