I have a view with an exposed filter that searches nodes for taxonomy terms. For example there are 10 terms but the nodes only use 7 of them. When the view is shown on a page the 10 terms show in the filter. 3 of the terms in the filter will yield zero results. I want to hide those terms (because they have zero results) and not make them available in the filter.
You can simply use Views Selective Filters Module for that.
Here is an introduction about this module :
This module allows to have an exposed filter only show options that belong to result set.
The options are calculated real-time with the current View's configuration, including the filters selected by the user so you get dynamic dependent filters, that is, when the value of one filter is changed, the list of options of the selective filters are updated accordingly to the trimmed down result set.