In your game xcode project source/GameName folder add a new group called UI or whatever. Drag a class in there. Now goto the unreal editor → Add new C++ class to the default game source folder. Unreal adds the class and recompiles your project. Your xcode project reloads with the UI group you just added gone.
This is due to XCode not actually creating a folder and not actually moving the source files themselves. Whenever you add a new C++ class, the project files are generated again based off the file structure of your Source folder. Since XCode doesn’t move these files around, they stay in the same location despite any changes made involving groups inside of the Xcode project. This means that when the project is generated, the new XCode project doesn’t have these changes. This behavior is the same for Visual Studio’s filters.
The best workflow for something such as this is to add the UI folder manually in the source/GameName folder, move the appropriate classes, and then generate your project files so that XCode can recognize your changes.