It is a fact that we become like who we associate with.
It does not matter how “strong” we are in the Faith or in morals.
If we are truly strong in these two areas, those immoral people will have no interest in associating with us and will naturally distance or excommunicate us from the family. I know from experience.
Remaining in the presence of those who sin is not only about being in the occasion of sin, but approving of their behaviour. It is a scandal whether those people perceive it to be or not.
We have a duty towards God first, and the other person’s salvation is last in the order of charity.
The devil often uses the thought “but you could save their soul” as a temptation under the guise of an act of virtue.
We think so highly of ourselves to believe we cannot be influenced. We are so blind spiritually as St. Louis de Montfort says, that these changes often take place imperceptibly.
One story St. Alphonsus Liguori related of this type of temptation occurring, was of a young girl who repented on her deathbed of impure acts with a young man. She suddenly received the inspiration from the devil (which she thought was from God) to invite that man over that he too may convert. He came, she saw him and she fell immediately and ended up damning herself.
We may learn from this even if our personal situation is not exactly this way.