Did the phone gets an update for software?
How about if you restart the phone like, HOLD the POWER Button>> TAP on Restart
will the phone boot to normal mode?
You can also try, while the phone is off, enter the Android Recovery Mode then wipe cache partition
to do this while the phone is off
HOLD down VOLUME UP and POWER BUTTON, once samsung logo appears, release all the buttons
if you see the green robot, wait for it till you get to a selection,
use the volume down keys to highlight, wipe cache partition (do not choose wipe data factory)
once selected, push the power button to select then you will go back to a screen selection saying, Reboot system now, click on the power button to reboot, now check if this boot to normal
If above fails, download "Smart switch" for PC from samsung.com/us website then connect the phone, let the smart switch fix the software.
If all of this fail, backup the phone using samsung cloud or PC, then schedule it for mail in for service of if there any availaable service location near your area.
The phone didn't receive updated on these three occasions. When I woke up I turned the phone off then back on and it started like normal.
I just don't know how it it gets into safe mode in my sleep
the phone will enter a safemode to prevent any further malfunction, like hardware or software. I would suggest to bakup the phone and send it for service. Since this is a bnew phone and there might be a failing components inside