Misery Loves Company Meaning

The phrase misery loves company means that if someone is miserable, they like others to be miserable too so that they can feel better about themselves.

Example: I see that you got into a lot of trouble, but since your colleague is in trouble too, that makes you feel better. Misery loves company, doesn't it?