Three possibilities:
Boys and girls are genetically similar in mathematical ability, but low SES boys and high SES girls underperform, both feeling they are socially more successful and not caring enough about being successful academically.
Boys are genetically more capable in maths. High SES boys and girls perform at capacity, low SES boys underperform badly because they can’t see the point at all.
Girls are genetically more capable in maths. Low SES boys and girls perform at capacity, high SES girls underperform badly, because…?
So, scenario 3 admittedly sounds.unlikely because whilst it is to be assumed that there are Social incentives for high SES girls to underperform, there are plenty of other incentives to not underperform so badly.
Interestingly, I got to chatting with the math and science of an all girls catholic college prep school (we live in a fairly conservative catholic area in Europe and there are a number of single sex schools left. College prep school means the school would cater to the upper third of the age cohort academically, so middle to high SES girls, academically capable, probably a few gifted kids in every classroom.
We got onto the topic of pros and cons of single sex schools, specifically whether all girls schools really encourage girls to not underperform in math. The teacher said she was interested in the topic as well, so always compared how their girls did on standardised tests compared to kids in mixed schools. In the middle school years, those would be wide problem sets, not multiple choice, no stakes for the teachers, just a small part of the year‘s grade for the kids, for junior and senior year in high school state wide final papers in math and science (mandatory calcupus, statistics and vector geometry for all, which would probably be considered an advanced math track in the US).
Throughout middle schools, the girls in single sex schools do worse than kids in mixed schools. But by junior and senior years (she said) the girls have caught up and do as well as kids in mixed schools (so overall, probably somewhat better than girls but worse than boys in mixed schools, but she didn’t have have access to data that detailed.
There is something that is happening in the middle schoolers early high school years, during puberty. I’d really like to know whether that pne might be biology and it is all about keeping girls engaged so they don’t get left behind, without that chance to catch up.
Edited to add that this doesn’t mean that boys might not need systematic engagement in other subjects, but math was the topic.