Q. If I gave tzdaka to a collector who turned out to be a fraud and a con, did I do a mitzva?

A. Poskim disagree whether giving tzedaka to a wicked or immoral individual is considered a mitzvah or no. Yad Remah (Bava Basra 9b,) deduces from the incident of Prophet Yirmiyahu (18: 23, Bava Kama 16b)) praying that the people of Anassoth even when they are prepared to do charity, Hashem should cause them to stumble and donate to the unworthy, that no reward is forthcoming for that charity.

Sefer Chasidim (61) adds that not only a mitzvah was not done, but also it would be considered an actual offense, since he is supporting undeserving and sinful individuals.

However, Gilyoney Hashas (Bava Kama 16b) deduces from Rabbenu Yonah’s permission to feed individuals who did not wash Netilas Yodaim, that one does comply with the mitzvah. Similarly, Nimukey Yosef (ibid.) maintains that if the givers intentions were to correctly observe the mitzvah, and he was unaware of the unworthy condition of the recipient, he complies with the mitzva.

The Chidah (Rosh Dovid, Shoftim) maintains that the above depends on the disagreement between Rabbi Meir and Rabbi Yehudah (Kidushin 36a) whether if Bnay Yisroel in a state of no compliance with the mitzvos are still called Bonim or Hasem’s Children.

Meromey Sade (ibid.) distinguishes between wicked or immoral people and individuals who fraudulently represent themselves as poor when they are not. Since you are not actually giving tzedaka to a poor man.

Horav Shlomo Miller’s Shlit”a opinion is that the giver complies with the mitzvah in the sense of someone who wanted to do a mitzvah and then he accidentally was not able to fulfill his wish (Kidushin 40a)

Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit”a