The Messenger of Allah ﷺ was asked about the children of the polytheists, and he said, "Allah knows best what they would have done."In another narration, "Allah, when He created them, knew best what they would have done."
سئل رسول الله ﷺ عن أولاد المشركين فقال: الله أعلم بما كانوا عاملين. وفي رواية: الله إذ خلقهم أعلم بما كانوا عاملين.
Bukhari related it in the Book of Divine Decree (6597), and Muslim in the Book of Divine Decree (2660), both from the hadith of Abu Bishr, from Saeed bin Jubayr, from Ibn Abbas, as mentioned. The second narration is also found in Bukhari (1383).As for his saying, "Allah knows best what they would have done," it means that Allah knew what happened, and He knows what will happen, and what would not have happened.