When the intention behind mixing with them is to call them (to the truth), – and it is done by those who have knowledge and insight – to adhere to the Sunnah and to abandon their error(s), then this is something good and is from calling to Allaah. However, if this mixing is only for the purpose of accompaniment and entertainment, without any da’wah and without any clarification [of their errors], then this is not permissible. Hence it is not permissible for a person to mix with the opposers except in a manner in which some Sharee’ah benefit can be attained, such as calling them to the correct Islam, clarifying the truth to them that they may return to it – such as when Ibn Mas’ood, may Allaah be pleased with him, went to the Innovators who were in the mosque, stood in front of them and rejected their innovation. And like Ibn ‘Abbaas, may Allaah be pleased with him, who went to the Khawarij, argued with them and refuted their misconceptions and as a result of which some of them returned to the truth.
Therefore, mixing with them in this manner is something that is desirable. But if they persist upon their falsehood, then it is obligatory to avoid and shun them and to struggle against them for the sake of Allaah.