SaveAsPrefabAsset causes nested prefabs to turn into regular objects

I make my levels in the map editor Tiled and have a custom importer that imports the map, builds a prefab and sets up other data based on the map information. For example in Tiled I can put an object called character with some data and then during the import it will load the character, put it on the map and save it as apart of the map prefab. The first time I import the map it will load nested prefabs. After the first import the nested prefabs will change to regular game objects and no longer be prefabs. I’ve narrowed the line of coding causing the issue to

PrefabUtility.SaveAsPrefabAsset(map.gameObject, $"Assets/Resources/Prefabs/Maps/{map.Data.MapName}.prefab", out var success);

Anyone have any idea why this breaks nested prefabs or any suggestions what to use to keep the nested prefabs intact?