The ultimate cure for a stubborn table of contents that will not update or generate is this:
Open your document and delete the table of contents you already have and save the document, then use the "select all" command to copy to your clipboard, then close that file.
Open a new document and paste the clipboard data into the new document (you may need to paste it into a text box), save the file with a new name and then build the table of contents.
What you did was fix a corrupted file that was causing TOC failures. There is no other cure for such corruption, but this advice works so you can get back to work.
I know, as my TOC on a book would not build and nobody's advice cured the problem. Just do what I did and you will have a fresh clean document once again.
Retrieving data ...