Figured it out. Here is the solution for UEnums, but it can be generalized to other class types as well:
You have to replace ANY_PACKAGE with nullptr and prefix the class name (eg. ECustomEnum) with “/Script/[YourProjectName].”
For example, if your project name is “TPSGame”:
Before: const UEnum* enumObject = FindObject(ANY_PACKAGE, TEXT(“ECustomEnum”));
After: const UEnum* enumObject = FindObject(nullptr, TEXT(“/Script/TPSGame.ECustomEnum”));
Note that this will only find enums that are defined within your project (Engine enums will return nullptr).
Also, for anyone who happens to be dealing with UEnums, I found another more general solution here:
Bonus tip: If you don’t know a class’s context, one way you can find it out is by using FindObject on the class’s name with the deprecated ANY_PACKAGE macro, then printing *GetNameSafe(class->GetOuter()) to the log to find out what it is.