The Ben Ish Chai (a”h), in Parashat Vayetze states that one should preferably eat the Seudah Revi’it (Melaveh Malkah) within four hours following the end of Shabat. In the winter months, for example, when Shabat ends at approximately 5:30pm, one would be required to eat the Melaveh Malkah meal between 8:30 and 9:00pm.
According to Rav Chaim Palagi (a”h), in his sefer Kaf Ha’chaim, one does not fulfill the mitzvah of Melaveh Malkah if he eats the meal four hours following the conclusion of Shabat. The Ben Ish Chai, however, maintained that the deadline of four hours applies only on the level of “Mitzvah min Ha’muvhar – the highest standard of mitzvah performance.” One who did not eat the meal before the end of four hours may, according to the Ben Ish Chai, do so until chatzot layla, (midnight as defined by halachah).
There is a third position taken by the Gaon of Vilna (a”h). He held that one may eat the Seudah Revi’it throughout the night, until daybreak.
It is told that the Vilna Gaon once took ill on Motzei Shabat and was unable to eat Melaveh Malkah. He went to sleep and later that night he woke up and felt capable of eating. He then asked his family to look outside and see if the sun’s rays were visible. They saw that no sunlight had yet appeared on the eastern horizon. The Gaon of Vilna then partook of a kezayit of bread to fulfill the obligation of Seudah Revi’it, clearly demonstrating that in his view, one who did not eat the meal before chatzot layla may still do so, until daybreak.
This is the view followed by Rav Ovadyah Yosef (a”h) in his sefer, Yechaveh Da’at and in his sefer, Halichot Olam.