reorganize mail folders (not in V4 on Sierra)
I just solved my problem by:


turning off all Internet accounts (keeping them on other iCloud machines)
updating to Mojave
following the steps in https://appletoolbox.com/mail-not-working-after-macos-mojave-upgrade-how-to-fix/, which basically deletes several Mail-related files in ~/Library/Containers and ~/Library/Mail.


This allowed me to recover my mailboxes and also recover a lost synchronization in Notes between my Mac and iPhone.