Firstly: You have to advise them and warn them of the evil consequences of dealing in haraam things and acquiring wealth from haraam sources. You should cooperate with your brothers among the righteous to remind them and warn them of the wrath of Allaah and the severity of His punishment of those who disobey Him and wage war against Him by committing haraam actions. You should teach them that the pleasures of this world are few, and that the Hereafter is better and more lasting. If they respond, then praise be to Allaah. In that case they are your brothers in Islam. Then you should advise them to return that which they took wrongfully to its rightful owners, if they know who they are, and to follow their bad deeds with good deeds, so that Allaah will accept their repentance and turn their bad deeds into good deeds. Then it will be permissible for you to mix with them as your brothers in faith, and to eat their food and accept their donations for building and furnishing the mosque etc., because by repenting and returning to people what is rightfully theirs as much as possible, their previous sins will be forgiven, as Allaah says (interpretation of the meaning):
“So whosoever receives an admonition from his Lord and stops eating Ribaa, shall not be punished for the past; his case is for Allaah (to judge)”
If they still refuse to heed advice and reminders, and they persist in doing haraam things, then you have to forsake them for the sake of Allaah, and not respond to their invitations or accept their donations, as a rebuke to them and, in the hope that this will deter them from committing evil actions.
And Allaah is the Source of strength.