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:28

That is because they followed what angered Allah and disliked ˹what earns˺ His pleasure, so He rendered worthless their deeds.  

That, taking of them away in the state mentioned, is because they followed what angers God, and ˹because˺ they were averse to what pleases Him, that is to say, ˹they were averse to˺ doing what pleases Him. Therefore He has made their works fail.
القرآن:٤٧:٢٨

ذَٰلِكَ بِأَنَّهُمُ اتَّبَعُوا مَا أَسْخَطَ اللَّهَ وَكَرِهُوا رِضْوَانَهُ فَأَحْبَطَ أَعْمَالَهُمْ  

{ذلك} التوفي على الحالة المذكورة {بأنهم اتبعوا ما أسخط الله وكرهوا رضوانه} أي العمل بما يرضيه {فأحبط أعمالهم}.

See similar narrations below:

Collected by Qurʾān
quran:47:9

That is because they disliked what Allah revealed, so He rendered worthless their deeds.  

That, wretchedness and wasting ˹of their works˺, is because they are averse to what God has revealed, of the Qur’ān with all that it includes of religious obligations (takālīf), so He has made their works fail.
القرآن:٤٧:٩

ذَٰلِكَ بِأَنَّهُمْ كَرِهُوا مَا أَنْزَلَ اللَّهُ فَأَحْبَطَ أَعْمَالَهُمْ  

{ذلك} التعس والإضلال {بأنهم كرهوا ما أنزل الله} من القرآن المشتمل على التكاليف {فأحبط أعمالهم}.