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:76:3

Indeed, We guided him to the way, be he grateful or be he ungrateful.  

Verily We have guided him to the way, We have pointed out to him the path of guidance by sending messengers ˹to mankind˺, whether he be grateful, that is to say, ˹whether he be˺ a believer, or ungrateful (both ˹shākiran and kafūran˺ are circumstantial qualifiers referring to the direct object; in other words, We have pointed out to him in both presupposed states, whether his gratefulness or his unthankfulness; immā is used to list the ‘states’).
القرآن:٧٦:٣

إِنَّا هَدَيْنَاهُ السَّبِيلَ إِمَّا شَاكِرًا وَإِمَّا كَفُورًا  

{إنا هديناه السبيل} بينا له طريق الهدى ببعث الرسل {إما شاكرا} أي مؤمنا {وإما كفورا} حالان من المفعول، أي بينا له في حال شكره أو كفره المقدرة، و إما لتفصيل الأحوال.