Messing around with it more, and have found everything works as expected and the math is all fine UNTIL I use it to call the value from the array. I checked and nothing is less than 0, I get the expected values at every step, but as soon as I subtract 1 (this value is confirmed to be not less than 0) and pass that to the array call, After Effects flips out. Stranger still, if I ADD 1, it works.
So if X=2 and I add 1 and pass that to the array I get, as expected, the value in the array[3]. And passing X unmodified to the array call gives me array[2]. But if X=2 and I subtract 1, I do not get the value in array[1] but the error “Undefined value used in expression.” However setting a variable to X-1 and just using that as my final value does indeed give me 1.
No idea what hidden magic is causing this to fail, but I’m just going to adjust my array values to match the returned value without doing any math to it.