Reference: Fataawa Noor ‘alad-Darb – Question No.6421, Page 249, Volume 12
Question: Is the presence of someone in a gathering where reprehensible acts are going on considered prohibited?
Response: Yes. It is not permissible for a person to remain in a gathering where reprehensible acts are going on, unless he is able to put a stop to them; so [in this case] he is obliged to remain there until he has put a stop to them. If, however, he is unable to put a stop to them, then he is obliged to leave the gathering, because Allaah (Tabaaraka wa Ta’aala) says:
…meaning that if you remain, you will be considered like them and share in their sin.
So it is obligatory upon him to put a stop to the reprehensible act – to the best of his ability, as the Prophet ﷺ said:
And it is absolutely not possible to detest it with the heart while remaining in the gathering, because to detest it with the heart [only] amounts to disliking the reprehensible act, while he should leave the gathering if he is unable to put a stop it.