Found the solution. For anyone else having this problem:
- Open the Visual Studio Installer
- Select ‘modify’ next to Visual Studio 2022
- Select ‘Individual components’
- Search for ‘MSVC v143 - VS 2022 C++ x64/x86 build tools (v14.30-17.0)’ and check the box
- Click ‘Modify’ to download the package
- Wait for it to install
- Close Visual Studio and Unreal (if open)
- Delete the .vs , Binaries , Intermediate , Saved folders and YourGame.sln
- Right click on the uproject file and generate the visual studio files
…and it should all work