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:40:34

And Joseph had already come to you before with clear proofs, but you remained in doubt of that which he brought to you, until when he died, you said, 'Never will Allah send a messenger after him.' Thus does Allah leave astray he who is a transgressor and skeptic."  

And verily Joseph brought you, before, in other words, before Moses — according to one opinion, this Joseph is the son of Jacob, having been given life until the time of Moses; according to another opinion this is Joseph son of Abraham son of Joseph son of Jacob — clear signs, manifest miracles, but you continued to be in doubt concerning what he had brought you until, when he died, you said, without any evidence ˹to support such a claim˺: “God will never send any messenger after him” — in other words, you will never cease to disbelieve in Joseph and others ˹that may come after him˺. So, that is, just as you have been led astray, God leads astray one who is a prodigal, an idolater, a skeptic’, a doubter of that which the clear signs have certified.
القرآن:٤٠:٣٤

وَلَقَدْ جَاءَكُمْ يُوسُفُ مِنْ قَبْلُ بِالْبَيِّنَاتِ فَمَا زِلْتُمْ فِي شَكٍّ مِمَّا جَاءَكُمْ بِهِ ۖ حَتَّىٰ إِذَا هَلَكَ قُلْتُمْ لَنْ يَبْعَثَ اللَّهُ مِنْ بَعْدِهِ رَسُولًا ۚ كَذَٰلِكَ يُضِلُّ اللَّهُ مَنْ هُوَ مُسْرِفٌ مُرْتَابٌ  

{ولقد جاءكم يوسف من قبل} أي قبل موسى وهو يوسف بن يعقوب في قول، عمَّر إلى زمن موسى، أو يوسف بن إبراهيم بن يوسف بن يعقوب في قول {بالبينات} بالمعجزات الظاهرات {فما زلتم في شك مما جاءكم به حتى إذا هلك قلتم} من غير برهان {لن يبعث الله من بعده رسولا} أي فلن تزالوا كافرين بيوسف وغيره {كذلك} أي مثل إضلالكم {يضل الله من هو مسرف} مشرك {مرتاب} شاك فيما شهدت به البينات.