Hello! I think this is a valid question.
I don’t know whether it is a sin to spend time with people. Remember people are people and if we locked ourselves up out of sight how can we bring the love of God to people - that is the first thing.
However, you do have a valid point about swearing and crude jokes. The answer depends on the level of cursing etc…if they do this all the time and you have said something or showed dislike for their obscene language and vulgarity and they do not attempt to change it when you are around then I think maybe limiting time with them is not a bad idea although without judging them as people.
I think the fact that you care about your faith and wish to heed a possible warning is righteous and if you think their behaviour might affect you then it is not a bad idea to spend a little less time with them. I would say that meeting new people who think the same way as you is a good idea because good people are important to have in your life. If we spend time in sinful places 24/7 then at some point this is going to affect us if we are not very careful, or maybe at least, weaken our resolve.
You could try not laughing when they make a crude joke, and if they ask why you didn’t, say something mild to suggest you don’t find it that funny. You don’t need to be rude but then they are rude if they are not being a bit more sensitive to other’s feelings. Sometimes silence can be a good protest. But I think your conscience is key to this scenario and a solution to the problem therein.
I would also reiterate the last poster’s suggestion of meeting with a priest. I don’t think there is anything wrong with your thinking here at all though.
Thanks for sharing!
God bless.