How can I get the currently selected objects in the outliner, if they are hidden?

I don’t think you need the operator FWIW. It’s one of the benefits of the new syntax for context overrides, it isn’t strictly confined to operator overrides anymore.

import bpy

override_context = bpy.context.copy()
area = [area for area in bpy.context.screen.areas if area.type == "OUTLINER"][0]
override_context['area'] = area
override_context['region'] = area.regions[-1]
 
with bpy.context.temp_override(**override_context):
    print([o for o in bpy.context.selected_ids if type(o) == bpy.types.Object])
1 Like