this one took a while to figure out. turns out, i had my trigger placed in the wrong location. I needed to place the trigger AFTER derivation/routing. And here is the revised code i ended up using:
$newGrid = max(array_keys(@=newGrid));
$i = 0;
foreach(@=newGrid as $r){
if($r['my_checkbox'] == "On")
{
$i = $i + 1;
@=newGrid[$newGrid + $i] = $r;
}
}