Sexual harassment claims are often defended in courts. There are many different possible defences that include intention, consent and the reasonable person standard.
Sexual harassment must be intentional. If the accused can prove that their actions were not intended to be harassing, then it is not sexual harassment.
If the victim voluntarily engaged in the behavior that is the subject of the harassment claim, then this isn’t sexual harassment as the behavior was agreed to.
Reasonable person standard
Another defence can be that the reasonable person would not have seen this behavior as harassing.