Without digging into it, you should be able to add the check for approved.
Here's the general SQL standard execution paradigm:
((select ... from ... where ... )
group by ... )
order by;
In other words, all the selects are done, and the results of that are grouped together, then the groups that have been grouped are orded.
Postgres actually blows it for UNIONs, but I've not bothered telling anybody (it's largely cosmetic in the ACS realm and nothing can be done about it until the planned massive rewrite of front-end postgres stuff happens, so I didn't see any real point).