As others have commented, the solution was to check for any windows belonging to a process that weren't visible and ignore those, while showing the others.
This was achieved by using the function IsWindowVisible(...).
IsWindowVisible(...)