One thing to be careful of there is the precedence (order) of the logical operators. "and" happens before "or" if you don't group them with brackets. You can think of "and" being like multiply and "or" being like addition.
So effectively what the if line was doing is:
if direction .x >= 0.01 or (direction .x <= -0.01 and direction .y >= 0.01) or direction .y <= -0.01:
That would mean pushing the thumbstick purely right would work, pushing it purely up would work, but pushing it left or down only works if there's a bit of both.
Cyber's way is easier, but if you wanted the explicit logic then it would work correctly as:
if direction .x >= 0.01 or direction .x <= -0.01 or direction .y >= 0.01 or direction .y <= -0.01: