From the diagram perspective there is two instances of the sub-process:
- One representing the collapsed, task like shape
- One representing the plane the sub-process spans (that contains all elements)
You have to find the plane for a collapsed sub-process and add the elements there:
const planeElement = elementRegistry.get(`${SUB_PROCESS_ID}_plane`);
modeling.createShape(..., planeElement);