If I remember right, older versions of AE required all return values to be sent with brackets, even a scalar value like an integer. Maybe not needed but for me it keeps the code more readable. Have never had any problems with it.
So I wasn’t replacing {} with [] – but was doing two separate things. If the {code block} only has one operation, as in the original post, the {} can be omitted. Secondly, just to try in case it would help, return the value via [].
Essentially doing something like if (levels<=5) { [0] }; just omitting the {}
When I tested the OP’s script I just had it drive a scalar value to see the output and didn’t test it driving a time remap – so it was returning the right values – I just forgot time remap uses seconds, not frames.