Earlier quoted context omitted.
Vivid dreams usually happen during REM sleep, which is the deepest phase of sleep. So if you are dreaming, you are probably getting good rest, even if it doesn’t feel like it, e.g. because you woke up suddenly during a dream, rather than after it.
Is REM not the least deep sleep?
I’ve seen deep sleep used synonymously with “deep NREM” (non-REM).
They are indeed different, but both support cognitive function in different ways.