A settings editor stores { ...settings } in an undo stack before editing settings.notifications.email. Undo restores the old outer object but not the old email preference. Explain what went wrong and how to update the setting without breaking history.
Spreading creates a new outer object, but settings.notifications is still shared. Mutating it changes what the history entry observes. Create a new settings object and a new notifications object with the changed email value. Reuse branches that were not changed and keep them immutable.
What a Strong Answer Covers
Explain shallow copying and identify the shared nested reference.
Copy the changed path instead of blindly cloning every branch.
Follow-up Interview Question · How would you test that the old history entry is unaffected?