This was caused by 9a03f283e8.
The change disregarded the `orig_layers_to_apply` mask and
introduced some issues regarding clearing keyframes of deleted layers.
The fix does two things:
* Add a `orig_layers_to_apply` set that contains the pointers of the
original layers that we want to apply.
* Add a `orig_layers_to_clear` set that contains the pointers of original
layers that need their keyframe cleared.
When a layer is removed during modifier execution, we don't want
the layer to be deleted in the original geometry. Instead we clear
the keyframes by deleting all the curves geometry. A layer
can be removed by e.g. using the `Grease Pencil to Curves` node to
get curve instances, then the `Delete Geometry` node to delete
some instances, and finally `Curves to Grease Pencil` to convert back
to Grease Pencil.
Pull Request: https://projects.blender.org/blender/blender/pulls/130028