When two (or more) inputs are directly connected you can iterate through each list simultaneously by zipping them together.
grid = IN[0]
bool = IN[1]
for g, b in zip(grid, bool):
You also don’t need to check a boolean with a test. You can simply use
if b:
this
else:
that