Trying to hide subcategories which have categories without posts

I ended up ensuring that all parent and grandparent categories are selected for a particular article, instead of just the child category.

That solved my problem. Now, sub-categories that have sub-sub-categories with posts are not treated as “empty”.