Delete Empty ActorFolders

I have a manager class that sorts a lot of actors into actor folders in the outliner, but it leaves a lot of empty folders behind. I’m trying to delete any empty folders, but can’t figure out why this doesn’t work:


if (Actor->GetLevel() && Actor->GetLevel() == GetLevel())
{
	if (SceneOrganisation.bKeepActorsOrganised)
	{
		FFolder ActorFolder = Actor->GetFolder();
		MoveActorToNewFolder(Actor);

		if (ActorFolder.IsValid() && ActorFolder.GetActorFolder())
			ActorFolder.GetActorFolder()->MarkAsDeleted();
	}
}

GetLevel()->CleanupDeletedAndUnreferencedActorFolders();

I’ve logged that all references are valid, and the Actor is successfully moved out of the original folder. I’ve also verified that the folder is in fact empty at the end of the loop, with all actors successfully moved to a new folder.