I personally think it is slightly dubious whether relative pronouns are truly grammatical subjects and objects, but for the purposes of your question, yes. Semantically the ultimate object is "bad thing", of course. the bad thing has happened to a person they deserve the bad thing
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.