This works. It is a working solution, but its far from ideal. As others have said, hiding layers this way obscures which layers are visible and not in the Layers panel. I much prefer to show / hide the layers via the built-in show / hide function which updates the dot next to the layer to represent what state each layer is in, and preserves what opacity you have each layer set to.
The devs are so close now. They have a 'Hide layer' shortcut, and separately a 'Show layer' shortcut setting, but why are they not the same shortcut as a toggle? It should be the same shortcut setting - so you press it and it toggles the state between hide and show. That's how it is in PS and its far better that way. Reduces the amount of shortcuts you need to remember, and is easier to toggle quickly.
Please combine 'Hide' and 'Show' into a single toggling 'Hide/Show' layer shortcut. Please.