—to a thief, a prostitute, and a wealthy man. He had wanted his donation to reach a self-respecting, upright poor person, yet Allah’s decree had already been set. It was therefore said to him, “Your charity has been accepted, for you were sincere and intended good, although what you wished for did not come about. The Prophet (peace and blessings be upon him) said in this regard: ‘When a judge strives to reach a verdict and errs, he still receives one reward.’ Likewise, you exerted effort but were unable to attain what you sought.
“As for your charity, it has been accepted. As for the thief, perhaps it will make him refrain from stealing, for he might think, ‘This money is enough for me.’ As for the woman of immorality, perhaps it will keep her from fornication, for—God protect us—she may have been selling herself for money, and now she has received something that spares her. And as for the wealthy man, perhaps he will take the lesson and spend from what Allah has given him.”
Thus a wholesome intention yields wholesome results. All of this is entirely plausible: the thief may abandon theft, the adulteress may give up fornication, and the rich man may take heed. This ḥadīth therefore shows that when a person intends good, strives for it, and yet falls short, the good deed is still recorded for him and he is not harmed by the error.
For that reason the scholars—may Allah have mercy on them—have said: If someone gives his obligatory alms (zakah) to a person he believes to be eligible and later discovers that the recipient was not entitled to it, the zakah nevertheless counts. Suppose, for instance, you see a man in threadbare clothes, assume he is poor, and give him your zakah, only to hear later that he is actually wealthy and possesses much money. Does your payment still discharge your obligation? Yes, it does, because, as the man in the ḥadīth was told, “Your charity has been accepted.” The same ruling applies if you give it to anyone else you thought was deserving but who in fact was not; your duty is still fulfilled. And Allah is the One who grants success.