Shaykh ‘Abd al-‘Azeez ibn Baaz (rahimahullaah) said:
“Keeping company with good people is one of the best of deeds that bring one closer to Allaah, and is one of the best means of attaining blessing. On the other hand, keeping company with bad people such as disbelievers and those who commit sin openly is not permissible, and is one of the things that lead to a bad end and cause one to adopt their attitudes and deeds.
What the believer must do is try hard to keep company with good people and avoid keeping company with bad people. It is not permissible to obey parents or others with regard to keeping company with bad people or forsaking good people, because the Prophet (blessings and peace of Allah be upon him) said: “Obedience is only with regard to that which is right and proper.” And he (blessings and peace of Allah be upon him) said: “There is no obedience to any created being if it involves disobedience to the Creator.”