I copied dependencies from a tutorial project that added 2 or 3 dependencies, I’m not sure which one exactly fixed the error, but here is the line of code I used:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "AIModule", "GameplayTasks" });
Its probably AIModule and GameplayTasks