What Rhino's for each actually did
Rhino (Apps Script's old JavaScript engine) implemented a non-standard Mozilla extension: `for each (var x in collection)` iterated over the *values* of an array or object, not its keys. It was never part of any ECMAScript standard, and V8 — the engine Apps Script switched to in 2020 — simply does not parse it. The syntax error you see when you enable V8 is not a migration quirk; Rhino's for each was always proprietary.
The confusion starts because the fix looks obvious: just delete the word 'each'. That gives you `for (var x in collection)`, which V8 accepts without complaint. The script runs. The logs look plausible. And then at some point you notice a sum came back as a string like '00.50.2511.75' instead of a number, or a conditional that should have branched on a value is branching on '0' or '3' instead.