Whether a human body is male or female is in nearly 100% of cases a relatively simple scientific question to settle, as I set out in my post.
Whether the person whose body it is should be treated as a man or as a woman is not a question that can be settled in the same objective way. It's basically a matter of social convention, for which we have to take responsibility as society and as individuals.
As I suggested in my post, I think that in nearly all cases the best way of proceeding is to find out how the person in question wants to be treated, and treat them that way. Cases where a person with a biologically male body uses that freedom of choice to harm others are rare, and just as we do not treat all people with male bodies who identify as men as violent and coercive rapists (although a very few are), there is no reason to view all people with male bodies who identify as women as if they posed a significant sexual risk to women.
The overwhelming risk of sexual violence or other sexual unpleasantness to women will always be found to come from people with biological male bodies who identify as men.