In case anyone isn't sure why the original interaction is harassment: relationships within a reporting chain are generally prohibited, for both legal, ethical, and practical reasons. Sex becoming part of the effective job description crosses both legal and ethical lines, and team effectiveness is hindered when people wonder whether someone is getting special treatment because they're sleeping with the boss. A manager…
Tech workers (across all disciplines) need to unionize to combat this kind of thing. As has been pointed out below, HR that is staffed and incentivized by the company management only serves the interests of the management. A union is the only structure that can actually win demands for workers by organizing workers to withhold their labor. It's not a panacea, and there are several historical examples of union leaders…
First they need articulable set of goals, based on a sound principled base. With such a base, to unionize or not is an implementation detail. But a union without guiding principles would be exactly the morally bankrupt negotiation tool unions are often accused of being. A union should never be more important to the unionized than the ideals it implements. Because if it ever is, the workers no longer control the union, the union controls the workers.
To that point, I have yet to see "tech" at large, or even software engineers seriously discuss principles for the purpose of a principled professional life. I hear complaints about individual things that are negative on the face have moralistic reasoning applied after the fact. But no guiding vision.
Just like we assume the people in movies poop [0] even though we never see it, an "obviously" unacceptable thing happening leads to have conversations resting on unspoken assumptions that someone solved what a professional environment is off-screen. If we want demands for what a work environment should be like to be taken seriously, we have to figure it out. Upfront, on-screen, and to create something people can believe in.
to combat this kind of thing
fight management on these kinds of issues.
Can you articulate what the KIND of issues are? The category can easily be labeled with synonyms for "bad" and easily have things like a misogynistic work environment placed within the category, but WHAT IS the category. What are the defining lines?
If every developer took the time to figure out what they believe in, or adopted the (e.g.) ACM Code to their professional life, it might not even take a union.