We are commanded by Allah to stop and eliminate all forbidden acts and to make our best to get others on the right path. Indeed, many vicious people would not be so if they found a merciful hand to take them out of the darkness of sins.
however, wisdom and gentleness sustained by sound knowledge are utterly required here. Then, if a person is not able to stop someone else’s wrongdoing with advice or the like, he or she should leave the place where misdeeds are done. This is for fear that the wrath of Allah may afflict him or her along with those who commit the forbidden acts.
Sheikh Muhammad Salih Al-Munajjid, a renowned Muslim scholar, stated,
It is not permissible to sit to people who drink khamr (i.e., intoxicant beverages), whether they are non-Muslims or Muslims. Almighty Allah says regarding those who sit to people who say words of disbelief, (He [i.e., Allah] has already revealed unto you in the Scripture that, when ye hear the revelations of Allah rejected and derided, [you] sit not with them [who disbelieve and mock] until they engage in some other conversation. Lo! In that case (if you stayed), you would be like them. Lo! Allah will gather hypocrites and disbelievers, all together, into hell) (An-Nisaa’ 4:140).
Imam At-Tabari said, “This verse is clear in prohibiting setting to people of falsehood of any kind, when they are indulging in their falsehood.” Ibn Kathir said regarding Allah’s saying (Lo! In that case (if you stayed), you would be like them.), “[It means] like them in sinning.”
Jabir reported that Prophet Muhammad (peace and blessings be upon him) said, “Whoever believes in Allah and the Last Day should not sit at a table on which khamr is circulated” (At-Tirmidhi).
Scholars who explained this hadith said, “[This applies] even if he or she does not drink with them, because this [i.e., setting to them] is the same as a ratification of their wrongness.”
Based on this, it is not permissible to sit to those people or to show courtesy to them. It does not matter if one does not drink with them, as one, in this case, is like a dumb Satan who sees abominable acts and does not denounce them.
What is obligatory is to censure their act and if they do not respond, one should leave them. May Allah protect us from all evils!