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:53:30

That is their sum of knowledge. Indeed, your Lord is most knowing of who strays from His way, and He is most knowing of who is guided.  

That, namely, the desire of this world, is the full extent of their knowledge, that is, the limit of their knowledge, namely, that they have preferred this life to ˹that of˺ the Hereafter. Truly your Lord knows best those who have strayed from His way, and He knows best those who are ˹rightly˺ guided: He has knowledge of both and will requite both.
القرآن:٥٣:٣٠

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

{ذلك} أي طلب الدنيا {مبلغهم من العلم} أي نهاية علمهم أن آثروا الدنيا على الآخرة {إن ربك هو أعلم بمن ضل عن سبيله وهو أعلم بمن اهتدى} عالم بهما فيجازيهما.

See similar narrations below:

Collected by Qurʾān
quran:6:117

Indeed, your Lord is most knowing of who strays from His way, and He is most knowing of the ˹rightly˺ guided.  

Your Lord knows best those who stray from His way and He knows well the rightly guided, and will requite both of them.
القرآن:٦:١١٧

إِنَّ رَبَّكَ هُوَ أَعْلَمُ مَنْ يَضِلُّ عَنْ سَبِيلِهِ ۖ وَهُوَ أَعْلَمُ بِالْمُهْتَدِينَ  

{إن ربَّك هو أعلم} أي عالم {من يَضل عن سبيله وهو أعلم بالمهتدين} فيجازي كلا منهم.
quran:68:7

Indeed, your Lord is most knowing of who has gone astray from His way, and He is most knowing of the ˹rightly˺ guided.  

Assuredly your Lord knows best those who stray from His way, and He knows best those who are guided, to Him.
القرآن:٦٨:٧

إِنَّ رَبَّكَ هُوَ أَعْلَمُ بِمَنْ ضَلَّ عَنْ سَبِيلِهِ وَهُوَ أَعْلَمُ بِالْمُهْتَدِينَ  

{إن ربك هو أعلم بمن ضل عن سبيله وهو أعلم بالمهتدين} له وأعلم بمعنى عالم.