The night at مزدلفہ is part of the حج journey, and the Sunnah is to pray Maghrib and Isha combined and shortened (qasr) upon arrival from عرفات, then rest until shortly before Fajr. If a حاجی falls asleep and misses the combined Maghrib and Isha نمازs, they must pray them as soon as they wake up, because نبی کریم (صلی اللہ علیہ وسلم) said: 'Whoever sleeps through a نماز or forgets it, let him pray it when he remembers it, for that is its time.' Prayer is never waived due to sleep or forgetfulness.
Regarding the stay itself at مزدلفہ, the majority of scholars (Hanafi, Maliki, Shafi'i) consider it wajib (واجب). The Hanbali school considers it a rukn (pillar) of حج according to one opinion, though the well-known position is that it is wajib. Sheikh Ibn Baz held that the stay at مزدلفہ is wajib, and missing it without a valid excuse requires a dam (sacrifice). If a حاجی was present at مزدلفہ even briefly during the night or before Fajr, they have fulfilled the requirement.
Sheikh Ibn Uthaymeen clarified that if a حاجی arrived at مزدلفہ, fell asleep, and woke up after Fajr having missed the entire nighttime دعا and the Fajr نماز at مزدلفہ, they should pray what they missed immediately. Their حج is valid because they were physically present at مزدلفہ. However, they missed the Sunnah of the lengthy دعا after Fajr at Mash'ar al-Haram. The stay itself was fulfilled by their physical presence during the night, even while sleeping.