Question is in the title, basically. Recently I was talking to a friend who feels like they deserve anything bad that happens to them. I thought this would fall under self-pity, but the person isn't blaming others or blaming factors outside of their control that have put them in their current predicament.
I'd use something like "Derisory" (adj.)
expressing a belief that something or someone is ridiculous or without value : expressing derision
So you could say that your friend is self-derisory for not believing they are worthy of good experiences or feelings.
Similarly, and perhaps more commonly: "Deprecating" (v.)
to criticize or express disapproval of (someone or something)
A little less harsh than derision, self-deprecation can often take a humorous slant to self-criticism.
I can think of a couple of phrases/idioms to echo the word you're trying to come up with such as
what goes around comes around
actions have consequences
If your friend acknowledges these phrases and the existence of karma, which is the belief that rewards follow good deeds while punishments follow bad deeds, then I would describe him or her as feeling "blameworthy". From Merriam-Webster,
being at fault : deserving blame
I chose this word because it seems like your friend feels responsible for a bad deed and deserving of any punishment. Good synonyms include "guilty", "reprehensible", and "culpable". All of these can express your friend's feelings.
There is a saying, that misery loves company. It's being comfortable being miserable, It is a self-loathing that is a familiar friend, It is a way of life, that drives a person to accept the abnormal, such as the severity and the cruelties of life as a perverse normality, expected and deserved. It is a redefining of oneself. It is what causes the whip of a Taskmaster, to be felt has purpose, care, and personal attention in the mind of a Slave. It is not what we are born with however it is instilled into us that this is Who We Are, usually through early childhood trauma either or both physical and emotional. As a Christian counselor we use the term "Inferiority Disorder" with the diagnosis of "Social Anxiety complex." It is I think, to prove yourself in a negative area because you are terrified in another area, real or imagined.
Perhaps they have a martyr complex ?
From Wikipedia ...
Martyr complex — In psychology a person who has a martyr complex, sometimes associated with the term victim complex, desires the feeling of being a martyr for his/her own sake, seeking out suffering or persecution because it either feeds a psychological need, or a desire to avoid responsibility.