Hide Categories with No Visible Products

Has anyone modified the categories list display so that it doesn’t show categories if the user is in a user group where all products in that category are not visible to that group? Otherwise you end up showing categories to click on that show no products.