The Kohelet Yitzchak writes that it is known that the Mitzvot and transgressions a person performs are not considered one against the other. Hakadosh Baruch Hu does not deduct the reward of a Mitzvah against the loss of a transgression. Rather, for the Mitzvah, He pays a good reward, and for the transgression, He punishes. However, sometimes it happens that Hakadosh Baruch Hu does not pay for the Mitzvah, and that is when one regrets the initial act, as found in Sefer Yechezkel (33:12): צִדְ קַת הַצַּדִּ יק לֹ א תַצִּילֶנּוּ בְּיוֹם פִּשׁ ְעוֹ – The righteousness of the righteous shall not save him on the day of his transgression. Chazal explain in the Gemara (Kiddushin 40b) that this refers to one who regrets their initial act of Mitzvah, because just as repentance erases the transgression – i.e., regret from the depth of the heart uproots the transgression from its root and it is as if it never was – similarly, when one regrets the Mitzvah he performed, the Mitzvah is completely erased, and it is as if it never was.
Kohelet Yitzchak explains that this is why it often happens that when a person does something good, he later experiences disrespect as a result. This often occurs among the community leaders when they establish something positive; afterwards, there arises great disputes over it, and they experience disrespect, and sometimes even financial loss because of it. This is the craft of the yetzer hara when he sees that he did not succeed in preventing a person from performing the mitzvah – he will later instigate hatred, disputes, jealousy, and enmity, hoping that through this, the person will regret the initial Mitzvah performed, and thus, not receive reward for it.