Feeling guilty

I where on a schooltrip in summer 2024. I shared a room with 3 other girls. We laughed a lot and at some point one of them started making jokes about a girl in our class. I can't remember what it was, but I laughed along. Simply because the entire situation before was funny. Since then I've felt pretty bad because she's actually quite nice. We don't have much to do with each other, but when we do, she's always really nice. I can't get it out of my head and I don't really like that kind of thing, but whenever I'm with that one girl it somehow slips out. I want to distance myself from her but don't know how since we have a lot of classes in common.

I generally have the problem of adapting to people so that I don't get excluded and am liked. In doing so, I disregard my moral principles and I hate it. I don't know how to change this, which is the reason why I prefer to be alone in my room. Can anyone relate to this?