I am always reminded of Terry Pratchett's Science of Discworld books with this discussion. Sex and sex determination is an area where there are many layers of 'lies to children', and people think they know better than someone because they know a layer or two more than the general population where actually the other person may be even more layers of complexity in.
The other problem is people commonly confuse sex determination with the definition of sex in general or the observation of sex in a particular individual.
Sex determination is a very complex and fascinating process. For humans, first layer of lies to children is that sex is XX or XY chromosomes. Second layer is understanding that it's actually whether or not there's a Y chromosome that matters. Third layer is understanding that it's not just the Y chromosome, but whether there's an SRY gene on it. Then we can go into hormones and ability to use them and all the different ways this process can be nonstandard resulting in DSDs.
The definition of sex is simple and used across biology. Sexual reproduction, small gametes, large gametes, a female organism or part is one that is structured to produce large gametes (regardless of whether currently or ever actually in the process of doing so).
The observation of sex in humans is in almost all cases entirely straightforward, take a peek inside the baby's nappy. Correct for everyone without DSDs and almost everyone with them. In a tiny proportion of cases doctors might need further checks. In an even smaller number, it may be a case of sitting down and having a discussion with the family, explaining what the child's biology is and how they're likely to develop. And occasionally, particularly in places with less sophisticated medical checks, it may be got wrong, for example for babies with 5ARD where actual sex is uncontroversial but the child's external anatomy may be misleading.
Going back to the definition of sex though, it's entirely irrelevant if there are genetic or gestation environmental factors that increase the chances of someone suffering dysphoria. Sex is not defined by how your brain is structured or how you feel about your body, it is defined by your body, specifically what gamete type you have structures to produce.