Should he shun his colleague at work who does haraam things?
Question

I have a colleague at work (who is a foreigner) who annoys me a great deal in the way he speaks and insults others, and even his cell phone has music with which he annoys me all the time. When I spoke to him about that, he said: This is none of your business. Now I have cut of all ties with him because of the situation between us. When I enter my office I say salaams in a loud voice and he does not answer me, and when he comes in he does not say salaams. Am I obliged to offer my hand to shake hands with him, knowing that I have seen with my own eyes that he does not care, and previously if someone shakes hands with him when he is sitting down he does not even bother to stand up because he is upset with that man? Does Islam require me to shake hands with him when he has the attitude that I have described? Please note that he does not speak to anyone else at work and I am not the first one to have this problem with him. I hope that you will reply because my conscience is troubling me and I am worried about the hadeeth which says “Deeds are not taken up (to Allah) because of disputes” or words to that effect.
Praise be to Allah.Shunning that may occur between two Muslims because of a dispute is of two types: 
1 – Shunning someone because of ego or worldly issues.
2 –Shunning because of the rights of Allah, because the person being shunned has fallen into innovation (bid’ah) or sin. 
The ruling on the first type is that it is not prescribed in Islam, rather it is forbidden. 
It was narrated from Anas ibn Maalik that the Messenger of Allah (peace and blessings of Allah be upon him) said: “Do not hate one another, do not envy one another, do not turn away from one another. Be, O slaves of Allah, brothers. It is not permissible for a Muslim to forsake his brother for more than three days.”
Narrated by al-Bukhaari (5726) and Muslim (2559). 
It is not permissible for this kind of shunning to go on for more than three days because of what it says in this hadeeth. 
The ruling on the second type is that it is a kind of shunning that is prescribed in Islam, and there is evidence for that in the Sunnah. This was done by the Sahaabah and by the imams of Islam after them, but it is subject to conditions and guidelines that have been discussed by the scholars. 
The Prophet (peace and blessings of Allah be upon him) shunned the three men who stayed behind from the campaign to Tabook with no excuse. The lengthy hadeeth about their story is narrated in al-Saheehayn from Ka’b ibn Maalik (may Allah be pleased with him), who was one of the three. 
Al-Haafiz Ibn Hajar (may Allah have mercy on him) said, discussing the lessons learned from this hadeeth: 
(One of the lessons we learn) is not saying salaams to one who commits sin, and that it is permissible to shun him for more than three days. The prohibition on shunning someone for more than three days is to be understood as referring to situations where the reason for shunning is not something prescribed in Islam. 
(Another lesson we learn) is that the obligation to return salaams is waived in the case of one who is greeted by the person who is being shunned, because if it were obligatory, Ka’b would not have wondered whether he (the Prophet (peace and blessings of Allah be upon him)) moved his lips in returning the greeting. 
Fath al-Baari (8/124). 
It is clear to us from the context of the hadeeth – which we will not quote here due to its length – that one of the rulings on the kind of shunning that is prescribed in Islam is that is it permissible not to give or return salaams to the one who is sinning – and even more so in the case of one who is introducing innovation – and that there is no time limit on shunning him, rather that may last until he repents or until the one who is shunning him thinks that the purpose has been served – as we shall see below. Hence you can see that there is nothing Islamically wrong with your not shaking hands with that sinner and not greeting him. To make the matter more certain: 
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said: 
If a person is known to openly fail to do obligatory duties or to do haraam things, then he deserves to be shunned and should not be greeted with salaams, as a rebuke to him, until he repents. 
Majmoo’ al-Fatawa (23/252). 
But it is essential to note that shunning of sinners and innovators has only been prescribed for important reasons, such as shunning him in order to discipline him so that he will give up his sin and innovation, and to warn others against falling into sin and innovation. If shunning has no effect on the sinner or only makes him more stubborn, then there is no point in shunning him, because of the bad consequences to which that may lead for the one who is shunned, or because it will not serve the purpose for which shunning was prescribed. In that case softening the heart of the sinner will be more effective than shunning him. 
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said: 
Shunning varies according to how strong or weak, and how few or how numerous the people who are doing the shunning are. The purpose is to rebuke and discipline the person being shunned and to deter the masses from doing likewise. 
If the purpose is more likely be to achieved by shunning, and it will weaken and reduce the evil, then it is prescribed, but if the person being shunned and others will not be deterred by that, rather the evil will increase, and the person doing the shunning is weak and the bad consequences will outweigh the good, then shunning is not prescribed, rather softening the hearts of some people is more effective than shunning. 
But in some cases shunning is more effective than softening the hearts. Hence the Prophet (peace and blessings of Allah be upon him) sought to soften the hearts of some people and shunned others, and the three who stayed behind (from Tabook) were better than most of those whose hearts were to be softened, because they were leaders who held positions of influence among their tribes. So the interests of Islam dictated that the hearts of the leaders be softened, whereas the three who were shunned were believers and there were many other believers besides them. So shunning them was supporting Islam and was a means of purifying them of their sins. Similarly what is prescribed with regard to the enemy is to fight them sometimes, and to seek truces with them sometimes, and to take the jizyah sometimes, according to circumstances and what is in the ummah’s best interests.  
Majmoo’ al-Fatawa (28/206). 
Shaykh Muhammad ibn Saalih al-‘Uthaymeen (may Allah have mercy on him) was asked: 
What is the guideline on shunning a sinner who does not commit sin openly in front of people, if there is an interest to be served by shunning him? 
He replied: 
The guideline is that if shunning a sinner will serve a purpose such as deterring him from his sin, then he should be shunned. But if it will serve no purpose, then shunning him is haraam, because the sinner is still a Muslim, no matter what major sin he may commit, except kufr if that is the case. This is well known. The Prophet (peace and blessings of Allah be upon him) said: “It is not permissible for a Muslim to shun his fellow-Muslim for more than three (days), each of them turning away if they meet. The better of them is the one who greets the other first.” So you should not shun him. And there are some sinners who, if they are shunned, will increase in sin and hate you as well, and will not accept any advice from you. But if shunning him will be of benefit, such as if he is one of your children or brothers, and he respects you, and shunning him will serve as a rebuke, then in the case you may shun him so that he will be rebuked. Then if you shun him but that does not work as a rebuke, then you should resume contact with him and greet him with salaam, and do not forget to advise him. 
Liqaa’aat al-Baab il-Maftoohah (231/question no. 9). 
If you think that not greeting him with salaam will have an effect on him and will work as a rebuke for his sins, then carry on shunning him and stop greeting him with salaam or responding if he greets you. But if you think that this is of no benefit, then remember that seeking to soften his heart with gifts, smiling at him and speaking kindly to him may be more effective than shunning him, so do that. If he refuses that from you, and does not respond to you, then there is no sin on you and you are not to blame for that. 
In Musnad al-Imam Ahmad (15823) it is narrated that Hishaam ibn ‘Aamir said: I heard the Messenger of Allah (peace and blessings of Allah be upon him) say: “It is not permissible for a Muslim to shun a Muslim for more than three days. If they forsake one another for more than three days then they are deviating from the truth so long as they are forsaking one another. If one of them attempts reconciliation first, that will be an expiation for him.   If he greets him with salaam and he does not respond or return his salaam, then the angels will respond to him and the shaytaan will respond to the other one, and if they die whilst forsaking one another they will never meet in Paradise!” 
Classed as saheeh by al-Albaani in al-Saheehah, 1246. 
We ask Allah to decree reward for us and you, and to guide us and you to what which He loves and which pleases Him. 
And Allah knows best.