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:61:5

And ˹mention, O Muhammad˺, when Moses said to his people, "O my people, why do you harm me while you certainly know that I am the messenger of Allah to you?" And when they deviated, Allah caused their hearts to deviate. And Allah does not guide the defiantly disobedient people.  

And, mention, when Moses said to his people, ‘O my people, why do you harm me — ˹for˺ they had said that he had a hernia in his testicles, which he did not have, and they denied him — when certainly (qad is for confirmation) you know that I am the messenger of God to you?’ (annī rasūlu’Llāhi ilaykum: this sentence is a circumstantial qualifier) and ˹when you know that˺ messengers ought to be respected. So when they deviated, when they swerved away from the truth by harming him, God caused their hearts to deviate: He turned them away from guidance, in accordance to what He had preordained since pre-eternity, and God does not guide the immoral folk, those who, in His knowledge, are disbelievers.
القرآن:٦١:٥

وَإِذْ قَالَ مُوسَىٰ لِقَوْمِهِ يَا قَوْمِ لِمَ تُؤْذُونَنِي وَقَدْ تَعْلَمُونَ أَنِّي رَسُولُ اللَّهِ إِلَيْكُمْ ۖ فَلَمَّا زَاغُوا أَزَاغَ اللَّهُ قُلُوبَهُمْ ۚ وَاللَّهُ لَا يَهْدِي الْقَوْمَ الْفَاسِقِينَ  

{و} اذكر {إذ قال موسى لقومه يا قوم لم تؤذونني} قالوا: إنه آدر، أي منتفخ الخصية وليس كذلك، وكذبوه {وقد} للتحقيق {تعلمون أني رسول الله إليكم} الجملة حال، والرسول يحترم {فلما زاغوا} عدلوا عن الحق بإيذائه {أزاغ الله قلوبهم} أمالها عن الهدى على وفق ما قدره في الأزل {والله لا يهدي القوم الفاسقين} الكافرين في علمه.