Checking Object.hide_get isn't enough to determine if an Object is hidden as it could also be disabled globally in the viewport (can be checked with Object.hide_viewport) or all the Collections the Object is in could be hidden either temporarily or globally, which would also hide the Object.
Object.visible_get can be used to test if an Object is visible, taking into account all visibility settings, alternatively, given a screen Context, Context.visible_objects provides access to all Objects visible in that Context, which is what this PR uses.
Only set Objects in the material list to OBJECT mode
Don't need to get the visible Objects again when they're already available in the material list. Currently the visible objects and material list should always be the same, but this change makes it more robust in-case the visible objects and objects in the material list can become different in the future
Use context overrides to set Objects to OBJECT mode without changing the active Object
Checking Object.hide_get isn't enough to determine if an Object is hidden as it could also be disabled globally in the viewport (can be checked with Object.hide_viewport) or all the Collections the Object is in could be hidden either temporarily or globally, which would also hide the Object. Object.visible_get can be used to test if an Object is visible, taking into account all visibility settings, alternatively, given a screen Context, Context.visible_objects provides access to all Objects visible in that Context, which is what this PR uses.