78 AH. Al-Walid came to power in 86 AH and died in 96 AH, so the rebuilding of the mosque and the incorporation of the chamber must have taken place within that span.
Abu Zayd ʿUmar ibn Shabbah al-Namiri relates in his work Akhbar al-Madinah—the Chronicle of the City of the Messenger ﷺ—on the authority of his teachers and those who reported from him that when ʿUmar ibn ʿAbd al-ʿAziz was acting as al-Walid’s governor in Medina in 91 AH, he demolished the mosque and rebuilt it with carved stone, roofed it with teakwood gilded with gold, tore down the apartments of the Prophet’s wives ﷺ, incorporated them into the mosque, and brought the grave inside as well.
Ibn ʿAbd al-Hadi then quotes Shaykh al-Islam Ibn Taymiyya:
‘When al-Walid enlarged the mosque and the chamber was enclosed within it, virtually all of the Companions had died; none remained except those who had merely seen the Prophet ﷺ and had not yet reached the age of discernment at which a child is instructed in purification and prayer. It is established by uninterrupted mass transmission that this occurred during the caliphate of al-Walid ibn ʿAbd al-Malik. They report that it happened in 91 AH and that ʿUmar ibn ʿAbd al-ʿAziz spent three years on the construction. In 93 AH many of the Successors died—among them Saʿid ibn al-Musayyib and the rest of the Seven Jurists—so that year is called “The Year of the Jurists.”’
In summary, the Prophet’s grave ﷺ was brought inside his mosque solely because the expansion made it necessary. Apparently no space was available on the other sides from which to extend the building, for ʿUmar and ʿUthman—may Allah be pleased with them—had already enlarged it toward the qiblah. They were therefore compelled to add area from the direction of the chambers, and thus his grave came to be within