Some Muslims attend activities which are closely linked to immoral people and include unlawful activities which the individual himself abstains from. A common justification for their attendance is that the Prophet ﷺ said, “Actions are by intentions,” and that they aren’t intending to do anything haram. While the hadith they cite is rigorously authenticated and agreed upon (meaning that al-Bukhari and Muslim narrated it in their compendia of rigorously authenticated hadiths), we must keep in mind that rulings cannot be determined after finding just a single piece of evidence. Rather, determination requires making an exhaustive search for all relevant evidence, and then interpreting it according to jurisprudence. After all: determining rulings is an act of ijtihad, a word whose root is j-h-d, which means expending great efforts. Keeping things simple: the hadith about intentions needs to be understood in light of other textual evidence that similarly apply to their activity. Similarly applicable evidence here includes the hadith that the Prophet ﷺ said, “Indeed, every king has a sanctuary, and Allah’s sanctuary is His prohibitions.” This hadith is also rigorously authenticated and agreed upon.
Imam al-Ghazali mentions this latter hadith in the chapter of Ihyaʾ ʿUlum al-Din pertaining to listening to poetry when discussing listening to musical instruments. One of the reasons he gives in support of it being unlawful to listen to musical instruments is that gathering to listen to them had become a signature feature of immoral people and that it is unlawful to imitate them since, as the Prophet ﷺ said, “Whoever imitates a people is one of them.” Abu Dawud narrated this hadith. So did Ibn Hibban, who also graded it rigorously authenticated. Al-Ghazali mentions an example scenario where people gather together in an assembly resembling a wine drinking party where, for example, sweetened milk is served in wine goblets. He says that it is unlawful for them to drink the milk in this setting – even though it is in itself lawful – since doing so imitates immoral people.
The gist of the reasoning is this: Otherwise-lawful x becomes unlawful when performed or used in a manner or setting that is a signature feature of immoral people.
I’ll leave it as an exercise for the reader to look for and ponder possible examples. But just ponder: don’t jump to any definite conclusions. The main point here is to think about the legal status of actions and to improve how we go about doing this.