There is evidence that more freedom and equality for everyone to be in any job they want leads to even less women choosing STEM careers (https://www.theatlantic.com/science/archive/2018/02/the-more...) That might be because of social issues you mention (harassment, under valued, talked over, underpaid, stalked, etc). It might also be a result of natural selection causing women and men to differentiate in useful ways wherein women were more attracted to nurturing roles, and men more attracted to technical challenges.
I don't think it's useful to pick one reasonable hypothesis and ignore other reasonable hypotheses. Let's explore all the useful ideas and recognize how little we actually know for sure.