This is a complicated sentence, but a correct one. The comma(s) in question act parenthetically. Without where they had to , there would be no commas needed.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.