Praise be to Allah.
What you should do is advise the person who is committing sin, whether the sin hurts you directly or not, because enjoining what is good and forbidding what is evil is an important obligation which Muslims are supposed to do all the time, as Allaah says (interpretation of the meaning): “And when a community among them said: ‘Why do you preach to a people whom Allaah is about to destroy or to punish with a severe torment?’ (the preachers) said: ‘In order to be free from guilt before your Lord (Allaah), and perhaps they may fear Allaah.’” [al-A’raaf 7:164]
In his tafseer (commentary) of this aayah, Ibn Katheer said: “Here Allaah is describing how the people of that town had split into three groups: those who committed sin by using tricks to catch fish on the Sabbath (which Allaah had forbidden them to do), those who told them not to do this wrong deed and boycotted them, and those who kept quiet, neither committing the sin not speaking out against it. But this third group said to those who were telling the sinners not to do it: ‘Why do you preach to a people whom Allaah is about to destroy or punish with a severe torment?’ i.e., why do you warn these people when you know they are doomed and they deserve to be punished by Allaah, and your telling them not to do it is of no benefit? The preachers said to them, ‘In order to be free from guilt before your Lord (Allaah),’ i.e., we are doing this out of obedience to your Lord, Who has instructed us to enjoin what is good and forbid what is evil; ‘and perhaps they may fear Allaah,’ i.e., perhaps this warning may make them stop what they are doing and return to Allaah in repentance, for if they repent, Allaah will accept their repentance and have mercy on them.”
The Muslim should use different styles of warning and calling people to Islam. Sometimes he uses a soft and encouraging tone, describing the rewards for obedience; sometimes he warns of the punishment for disobedience; sometimes he may tell stories which illustrate an important lesson; sometimes he explains the bad consequences of sin on the person’s life, and so on.
If a person can no longer bear to be close to this sinner, and there is no benefit in advising him, then he should keep away from him and have nothing to do with him. And Allaah is the source of strength and the Guide to the right path.