Also make sure the hall wires, the 5 thin ones, match up between the new motor and controller. Colours are not standardised, so find + and - and the other 3 may need to be changed.
Most of the major players use standard hall wiring, Bafang, Mxus, Aikema ,Yose, Xiongda, etc.
As do the major players with controllers.
Red & Black, Blue A, Green B & Yellow C with White as speed sensor. Just make sure colours match.
Granted some obscure or cheap China suppliers may be different.
Esp controllers that only use the same 3 colours repeatedly.