It is conditional concerning spending the Night in Mina that it is for most of the Night
Question :
What is the ruling on whoever spent the night in Mina until 12:00 am at night, then he entered Makkah and did not return to Mina until the beginning of Fajr time?
Answer:
If 12:00am at night was the middle of the night in Mina, then there is no harm in leaving it afterwards, even though it is better to stay in Mina during the day and the night. If 12:00 am was before the middle of the night, then he should not leave, because it is a condition of spending the night in Mina that it is for most of the night, according to what our Fiqh scholars have mentioned - may Allah have mercy on them.
Source:
Ash-Shaykh Ibn 'Uthaimin
Fatawa Islamiyah, Vol. 4 Pages 231-232