To cut off your nose to spite your face

An unnecessarily self-destructive response to a problem.

e.g. my best friend’s 21st birthday party is this weekend but I am not going because my ex-girlfriend may be there. My brother said I shouldn’t cut off my nose to spite my face.

Spite is a desire to hurt, annoy or offend someone - often in anger or hurt.
It’s often used as a warning not to do something that would harm you more than the other person out of anger or revenge.