Scripting: move selection to layer doesn't work if layer is not visible
When moving selected elements to a layer, if that layer's visibility is set to false, it reports that it cannot move elements to a locked layer. However, it's not locked, it's just not visible. I do this all the time by physically dragging to a layer that is not currently visible. I was able to work around it by setting visibility to true, moving the elements, then making it false again, but it seems like a bug.
Michael Reilly shared this idea
It can be done manually, so it is expected to work in scripts too.