
The joke’s on somebody
Self-Defeating Humor
This phrase often highlights an ironic situation where someone's attempt to be funny at another's expense backfires on themselves. 
Unintended Outcome
Use when someone's plan or action has the opposite result of what was intended, especially in humorous or playful contexts. 
Schadenfreude Caution
It warns of the possibility of finding oneself in an embarrassing situation after trying to embarrass someone else. 