I think the problem is not related to include order but to where exactly is the wifi.h file and how it is included. I suspect wifi.h to be in the same directory as main.c, while main.h is in another directory. If you do the include using quotes, then the compiler search first alongsides the file that do the include, so including from main.c may work while from main.h it may fail.
Note also that projects generated from CubeMX tend to include linked files, that appear at one place in the project explorer but are ine fact somewhere else on the disk... This may cause the same kind of problems.
To check for this you should look at your project directory from the Windows file explorer to check where exactly are located the files (you may also check a specific file by right-clicking it in the project explorer then “Properties...”, if it’s a linked file it will be shown in the first tab).
Hope this helps clarifying things,