When babies smile in their sleep it's called neonatal smiling or reflex smiles which is a normal reflex that the baby cannot control.
A baby smiling while they are sleeping or sometimes at other times does not always mean the baby is happy or thinking about something happy.
Babies smiles are called “reflex smiles.”
Babies start reflex smiling before birth and continue to do so as newborns.
These smiles happen randomly and reflex smiling usually stops around 2 months after birth, right around the same time you can expect baby's first real smile.