Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:47:32

Indeed, those who disbelieved and averted ˹people˺ from the path of Allah and opposed the Messenger after guidance had become clear to them - never will they harm Allah at all, and He will render worthless their deeds.  

Indeed those who disbelieve and bar from the way of God, the path of truth, and defy the Messenger, opposing him, after the guidance (this is the meaning of ‘the way of God’) has become clear to them, they will not hurt God in any way, and He will make their works fail, He will invalidate them, ˹good works˺ such as voluntary alms and the like, and so they will not find any reward for it in the Hereafter — this was revealed either regarding those ˹Meccan˺ participants at ˹the battle of˺ Badr who provided food ˹for the needy˺, or regarding ˹the Jewish tribes of˺ Qurayza and al-Nadīr.
القرآن:٤٧:٣٢

إِنَّ الَّذِينَ كَفَرُوا وَصَدُّوا عَنْ سَبِيلِ اللَّهِ وَشَاقُّوا الرَّسُولَ مِنْ بَعْدِ مَا تَبَيَّنَ لَهُمُ الْهُدَىٰ لَنْ يَضُرُّوا اللَّهَ شَيْئًا وَسَيُحْبِطُ أَعْمَالَهُمْ  

{إن الذين كفروا وصدوا عن سبيل الله} طريق الحق {وشاقوا الرسول} خالفوه {من بعد ما تبيَّن لهم الهدى} هو معنى سبيل الله {لن يضروا الله شيئا وسيحبط أعمالهم} يبطلها من صدقة ونحوها فلا يرون لها في الآخرة ثوابا، نزلت في المطعمين من أصحاب بدر أو في قريظة والنضير.