The Mahdī will be from the Fāṭimah's bloodline
The Prophet ﷺ said: The Mahdi will be of my family, of the descendants of Fatimah. Abdullah ibn Ja'far said: I heard AbulMalih praising Ali ibn Nufayl and describing his good qualities.
سَمِعْتُ رَسُولَ اللَّهِ ﷺ يَقُولُ الْمَهْدِيُّ مِنْ عِتْرَتِي مِنْ وَلَدِ فَاطِمَةَ قَالَ عَبْدُ اللَّهِ بْنُ جَعْفَرٍ وَسَمِعْتُ أَبَا الْمَلِيحِ يُثْنِي عَلَى عَلِيِّ بْنِ نُفَيْلٍ وَيَذْكُرُ مِنْهُ صَلاَحًا