Catalina ask password to delete user but password is always wrong

I start to think this might be a bug in Catalina.

STEPS TO REPRODUCE:

  1. I formatted my Mac-mini to factory reset (don't remember if was High Sierra or Mojave)
  2. I created a user at first startup.
  3. I upgraded to Catalina
  4. After Catalina installation I create a few users admin and non
  5. With a new admin user I can delete other admin or standard users without problem but I cannot delete the user created previously to Catalina. The message says:

to delete the user you need to enter their password

I did it several time, is the password I still use it to login with that user and it won't delete the account.

(See the problem when I try to delete the 4th user: no options is prompted)

enter image description here

So there must have been some sort of change between OS version and users created after Catalina cannot manage users created before Catalina.

I also tried to change the password for the user, the problem persists.

I also tried to remove the user through Terminal, no joy:

sudo dscl . -delete /Users/"yourusername"

returns:

<main> delete status: eDSPermissionError

<dscl_cmd> DS Error: -14120 (eDSPermissionError)

I found the solution!

This was a user I created after the factory reset and therefore was created on High Sierra.

macOS High Sierra has a bug around the user 501 which is the very first user you create after login:

https://medium.com/@ambroselittle/cant-delete-original-admin-user-on-macos-high-sierra-1d79fb438246

https://discussions.apple.com/thread/8087348

So what we are going to do now is substitute the user you want to keep with the user 501 that you want to delete. Is a bit hacky but it worked on my Catalina:

  1. System Preferences > Login Options > Join… > Open Directory Utility…
  2. Click to unlock it. (You may need to Enable Root User in Edit menu.)
  3. Go to Directory Editor. Search to find the user you can’t delete — the original user that was logged in when upgrading to High Sierra.
  4. Find the GeneratedUID field on the right and copy it somewhere safe.
  5. Change one digit in it and Save.
  6. Find your new/main user account > GeneratedUID, paste in the one copied above. Save.
  7. Run diskutil apfs updatePreboot / in Terminal.
  8. Reboot.
  9. Login as your main user. You should be able to delete the original user now.

Strange that the upgrade to Catalina is not backward compatible and doesn't fix the issue related to previous users.