Modifying the visibility of objects is a permanent change that will be saved with the layout and you need to revert it the same way as you applied the change, maybe selecting the appropriate objects from the panels instead.
For temporary changes I recommend using the focus mode feature instead.