Unable to "move" layers to new parent layer

I think I found a solution here Create Layer Hierarchy in C# - #6 by netlander

So it seems that adding the layer to the doc and seeing it there in the layers browser is not enough because it doesn’t have an established Id…even though it’s there and you can see it!
Anyway, the trick is to get the newly created layer again from the LayersTable. That one will have an Id that you can then use to set the other layers’ parent Id.

So you need to add this after having created the layer:

Layer surveyLayer = doc.Layers.FindName(surveyLayerInMemory.Name);

Hopefully this helps!

Cheers