the joke's on me

the joke's on me / him /her /etc — (Это) я / он / др. остался в дураках; что-л. обернулось против меня / него / нее/ др.

Used to say that the joke you were playing on someone else is actually a joke being played on you. It doesn’t have to be a joke. It can be an idea too. Somebody who tried to make you look ridiculous / stupid now looks ridiculous instead.

Example 1: I bought the computer for $100 and thought I was getting a great deal until I got my bill. It was $100 plus $85 for shipping. I guess the joke was on me. (David W. Miller)

Example 2: I couldn't think of a good way to get out of the relationship, so I came up with a plan. I asked my closest buddy to flirt with her one night when I was out of town. Since he'd always thought my girl was good-looking, he agreed, and the next weekend, they kissed at a bar. When I got home the following day, I confronted her, pretending to be really upset. She felt awful, and I ended up dumping her on the spot. But the joke was on me because they wound up getting into a serious relationship. Now I see her all the time... hanging all over my best friend. (Cosmopolitan)

Example 3: Annika never worried if people laughed at her. She always assumed everyone else was in on the joke and I've always assumed the joke was on me. When I was eleven I was mortified if I wasn't wearing the right shoes to school. But Annika just never cared what other people thought. Maybe if you don't care, other people don't care much either. Maybe it's like how dogs only bite people who are afraid of them. ( Brian Strause, "Maybe a miracle")

Related vocabulary:

the tables are turned AND turn the tables on sb in [все наоборот]