I have finally figured out how to remove those stubborn grey/italicized folders in Thunderbird you can not remove. The issue is there is a separate list of “subscribed” folders defined in a file in your imap server the specifies what folders your client should download. However you may have deleted those folder or that file may contain illegal characters (such as tabs instead of spaces) that prevents any tools to remove them.
The solution is to ftp or ssh into your mail server and open the subscription file and manually erase those problematic entries that contain the bad characters.
You can see I have marked the folders that were causing me the problems in red below.
You can find the subscription file by going into your mail server and for me it was located at:
/imap/domain.com/emailname/Maildir/subscriptions
Remove those lines and save, and you should be good to go.
Don’t waste your time trying to modify it programatically via python scripts and imaplib. These libraries just don’t allow you to work with the subscription folders with bad characters so you can’t write a function to rename it or delete it. Just access the file manually and delete it.
I was able to setup ftp for my email account in directadmin and create an ftp account there. I am sure cpanel would also let you access the mail folder as well.