It is one of the blessings of Allaah that such questions as this are raised, which indicates the extent of the concern that the questioner feels for her religion and her desire to pursue the means of remaining steadfast in it, one of which is avoiding keeping company with people who commit sin. We ask Allaah to make us and her steadfast in adhering to his religion. This question may be answered in the following points:
1 – Openly committing sin is one of the causes of a person being deprived of the forgiveness of Allaah. The Prophet (peace and blessings of Allaah be upon him) warned against this when he said: “All of my ummah may be forgiven except for those who commit sin openly.” (Narrated by al-Bukhaari, no. 60696). This is a great sin, and we ask Allaah to save us from it.
If a person sits with people who sin, either of the following two scenarios must apply:
Either he sits with him at the time when that person is committing the sin.
In this case it is not permissible for him to sit with him so long as he is still sinning, unless he is able to put a stop to it by advising him or in some other way. If the evil action is stopped then it is permissible for him to sit with him. Allaah says (interpretation of the meaning):
“And it has already been revealed to you in the Book (this Qur’aan) that when you hear the Verses of Allaah being denied and mocked at, then sit not with them, until they engage in a talk other than that; (but if you stayed with them) certainly in that case you would be like them” [al-Nisa’ 4:140]
But if the person does not stop committing the sin, then he must leave the gathering, but it is better to explain to (the sinner) the reason for leaving, if that will have an effect on him and prompt him to give up the evil action.
The second scenario is when the person is not committing sin at that moment, in which case it is permissible to sit with him and there is no sin in that.
2 – You ask whether you should stop being friends with them, or not.
The answer is:
If the sister is confident that she will not be led astray because of them and she thinks that some good can come of being friends with them, in the sense that she can continue to advise them and tell them what is good for them, then in that case continuing to be friends with them is better. We ask Allaah to give her strength and support.
But if she thinks that they may have an influence on her if she mixes with them a lot and gets used to what they are doing, then she should not sit with them and she should give up her friendship with them, in order to protect her religious commitment, especially if she has already advised them several times and they have not responded.
Then if she thinks that she can look for others whom she can try to advise, she will be rewarded for that.
And Allaah knows best.