Have the last laugh

To make someone seem foolish for laughing at you first.

I had the last laugh when I went home early while everyone else had to work late.