Unfortunately Google Docs does not support hiding specific heading levels.
The only “solution” would be to change the headers you want to hide to the “Normal” style, then manually set the font formatting for each heading.
The only way to avoid all headings from being added to the TOC is to manually apply the style you want rather than using the set styles. Change those headers to “Normal” style by select each one individually and pressing Ctrl + (Control plus the backslash key). This will remove the formatting. Then manually add the point size, font, and bolding that you want.
To easily copy formatting from one place to another, you can use the Paint Tool. So once you manually change one heading, you can use the Paint Tool to change others that are the same level heading.
– Source: Google Docs Forums: How to show only Heading 1 in table of contents
What I did to solve the problem which is probably doc specific, but I was using H1 through H3, what would have been H4 I didn’t want to show up in the TOC. I converted all the H4’s to Subtitles, then styled Subtitles the way I wanted it.
Subtitles don’t show up in the TOC.
How to convert all headings into another heading:
The previous answers suggests setting the style of headers to “Normal” and manually setting their style to look like a header. If you do so, you will lose the ability to link to that header from within the document.
It looks like you can actually manually delete items from the table of contents. I think that’s a simpler approach.