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.
The basic principle in the Sharee’ah is that it is not permissible to desert a Muslim for more than three days.
Anas ibn Maalik narrated that the Prophet said: “(O Muslims!) Do not hate each other, do not envy one another, and do not be hostile to one another (standing back to back); rather, be brothers (as) servants of Allah. A Muslim is not allowed to desert his brother (Muslim) more than three days.” [Muslim]
According to the view of the majority of scholars, desertion is eliminated by simply greeting the person or returning his greeting.
Ibn Hajar said in Fat'h al-Baari:
“Most scholars said that desertion is negated by simply greeting (a person) or returning his greeting.” [End of quote]
However, if there is any harm on you in your religion or your worldly life, that cannot be removed except by deserting a specific person, then it is permissible for you to desert him for more than three days, and there is no sin on you in this case.
Ibn ‘Abd al-Barr said in at-Tamheed:
“The scholars agreed in a consensus that it is not permissible for a Muslim to desert his fellow Muslim more than three days unless he fears by talking to him and keeping ties with him what spoils his religion or causes harm to him in his religion or worldly matters; if this is the case, then he is given concession to desert him and stay far away from him; indeed, a good cutting of ties is better than a harmful mixing (with others).” [End of quote]
Allah knows best.