All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Allah, The Exalted, says (what means): {And (they are) those who do not testify to falsehood, and when they pass near ill speech, they pass by with dignity} [Quran 25:72]
The verse means that they deem themselves exalted from partaking in falsehood (vain and idle talk) and turn away from it.
As-Saʻdi commented on the verse saying, "It means that they deem themselves far above engaging in such falsehood..."
Adhwaa' Al-Bayaan (book) reads, "It means that when they pass by people who engage in vain and idle talk, they turn away from them, deeming themselves far above the indulgence in such falsehood …"Ibn Katheer
wrote, “They do not attend where falsehood occurs, and if it so happens that they pass by it, they do not let it contaminate them in the slightest.” [Tafseer Ibn Katheer]
Al-Qurtubi commented on the verse saying, “The word Laghw used in the verse incorporates all the sinful acts and the word Kiraaman (with dignity) means they graciously turn away from such sinful acts; they dislike and do not approve them. They do not take side with those who commit such sinful acts nor do they attend such sinful gatherings …”
Thus, you come to realize that the verse does not mean that they should be generous with the sinners in the common sense of the word; in fact, a persistent sinner is not worthy of generosity. Scholars held that a sinner should not be greeted especially during committing the sin in order to deter him from such a sin and discipline him.
The Hanafi scholar Al-Khaadimi wrote, “A dissolute person who is committing sinful acts openly should not be greeted. According to the usage of the Arabic language, this statement indicates that such a dissolute person should not be greeted while committing the sinful act openly. However, the first thing that comes to one's mind upon hearing the statement is that such a dissolute person should not be greeted at all times in order to deter him from such sinful acts ...” [Bareeqah Mahmoodiyyah]
An-Nawawi wrote, “As for the one given to religious innovations or has committed a grave sin and has not repented to Allah, The Exalted, of such a sinful act, he should not be greeted and his greetings should not be returned as well. Al-Bukhaari and other scholars held such a view ...” [Al-Athkaar]
Ibn Muflih wrote, “It is disliked for a Muslim, who is competent for religious assignments, to keep the company of someone playing the chess or someone who plays with the dice or greet him. Rather, he should forbid such a sinful act and forsake him if he persistently continued to commit such sinful acts. Shaykh Taqiyud-Deen related that Abu Haneefah, Ahmad, and others held that a Muslim should not greet the person who plays chess because he commits sins openly...” [Al-Adaab Ash-Sharʻiyyah]
Ibn Hajar wrote, “The majority of scholars maintained that the dissolute person or the one committing religious innovations should not be greeted ...” [Fat-h Al-Baari]
He also wrote, “Al-Mulhab stated, ‘Refraining from greeting the people given to sins has been an ongoing practice encouraged by many scholars regarding those given to religious innovations.’”
Allah knows best.