What should one do if they want to donate to a masjid but they are not upon the sunnah?
It is allowed to donate to a masjid that has some innovations occurring in it.
Shaikh Abdul-Muhsin al-‘Abbad was asked:
Is it allowed for me to aid with my money in building a masjid and in this masjid some innovations are established like the innovation of Mawlid?
If the people are in need of a masjid and you assist them in it, this is good and he will be rewarded. If there is a detestable action, then the one who does that will have the sin. As for a person assisting in a building a masjid that the prayer is established in and this detestable action occurs in it, then this one is like one who prays with a thawb that is raised or a thawb that is made of silk.The prayer is valid, but the action he did is prohibited. So a person assisting in building a masjid and there are in it people who do that action [innovation], he is upon good and they are upon evil.
[Sharh Sunan Ibn Majah no. 60]
However, if this masjid is of the People of innovation who are against the Ahlul Sunnah and call to innovation, then one should not donate to them.
Shaikh Yahya ibn Ali al-Hajoori was asked:
Is it necessary to build Masaajid in the lands of disbelief? If the answer is yes, do we assist in helping with those who are not Salafiyeen if they are responsible in building some Masaajid?
He said: “…. There is no doubt helping in building Masaajid for the Muslims is desired whether in the lands in the disbelief or the lands of Islam except there is another notification: that you do not cooperate with the people of desires. Not in building masaajid for them even though building masaajid is a good deed and piety. Except that they will harm Ahlul-Sunnah and will assist in spreading innovation and succeed in what they are upon of oppositions and solicit people to these places. Allah the Exalted said:
وَتَعَاوَنُوا عَلَى الْبِرِّ وَالتَّقْوَى وَلَا تَعَاوَنُوا عَلَى الْإِثْمِ وَالْعُدْوَانِ وَاتَّقُوا اللَّهَ إِنَّ اللَّهَ شَدِيدُ الْعِقَابِ
Help you one another in Al-Birr and At-Taqwa (virtue, righteousness and piety);but do not help one another in sin and transgression. And fear Allah. Verily, Allah is Severe in punishment.
And soliciting people [to this] is sin and transgression”
And Allah Knows Best
Faisal Ibn Abdul Qaadir Ibn Hassan