I'm not talking about what was going through his head, or any psychological analyses. (I notice you did, though. Not even sure where you're getting this psychology thing from.
I'm talking about the layers of meanings of what people are saying when they talk to each other, what's explicit and implicit and how human communication has a lot of tricky ways of getting different types of things across to other people.
Still assuming the friend was mocking misogynist rapists:
We can understand the joke in that we get why a nasty misogynist would find "maybe-equals-yes" type jokes funny. We can then also understand it on the level where we laugh at the irony of a decent bloke pretending to sound like a misogynist in order to mock them.
We can also understand it on the level of what a person is communicating about themselves via what they choose to say. When you mock or criticise someone in some way for something, you generally implicitly position yourself in relation to the person you're mocking or criticising — different, or opposing, or better, generally something like that. We automatically listen for this kind of social and relational communication lying beneath what people say.
The ways that we use what we say to communicate with each other on multiple levels means that when it's coming from a man towards a woman, the friend's rape joke — even if intended as anti-rapist — can easily result in discomfort if the woman feels she's being implicitly invited to consider what makes this man different to rapists.
Or of course the conversation might not develop that way, different people might prioritise different aspects of what's being communicated, or they might understand it in different ways…
What I'm saying is that arguing, "But the joke was against rapists and mocking misogynists so it's fine" doesn't work well as a blanket statement, especially when the circumstance is a man joking about rape to a woman shortly after she discloses a recent uncomfortable situation with a man. There are lots of ways ways that making even an anti-rape rape joke can result in communication that hurts someone or gives an unintended negative impression, resulting in upset people and damaged relationships; I was just talking about one way that could happen, as an example.