Regenerate the project files by first deleting the .vs, Intermediate, Binaries, Saved folders and the .sln file, then right click on the .uproject file, and under more options click on the Generate Project Files option.
If that doesn’t fix the issue, there’s a longer way that ensures it: Delete the .vs folder, Source folder and the .sln file, open up the .uproject file, inside the editor, navigate to the Tools menu and create a new C++ class, make it public, then close the editor and head back to your project folder, open up the newly generated Source folder, then into the folder with your project name, and under there you should see two folders named Public & Private. Go ahead and replace them with the original ones, and you should be able to build the project with no issues!
Disclaimer:
Make sure to have a backup of your project before manually adjusting the project files!!!