Someone leaves the household or the team, and their account holds folders others still need. Deleting the user would take the files along, so move them first.
Name the source user, then the destination:
docker exec --user www-data nextcloud php occ files:transfer-ownership layla fred
The files land in a new subfolder in Fred’s home, so nothing gets mixed up with his own. You can also move a single folder:
docker exec --user www-data nextcloud php occ files:transfer-ownership --path="Documents/Project" layla fred
--move puts the files directly in the destination’s root instead of a subfolder, meant for an empty account. Files that others had shared with Layla are not included unless you add --transfer-incoming-shares=1.
My habit would be to take a database dump and a copy of the data folder first, then check Fred’s account in the web interface, open a few files, and only then disable the old user. Disabling for a while is gentler than deleting right away.
Fred needs room: the files count against his quota from now on. If server side encryption is enabled, both accounts need to be in a usable state, so read that part of the manual before running it. Large transfers take a while, and you shouldn’t interrupt the command halfway.
Further reading: Nextcloud occ files commands
Going deeper: Guide: link Prowlarr to Sonarr and Radarr once, and stop typing indexers into every app