Image illustration of what I'm trying to get:

I'm mapping through this parent array with an array of children that has an object children.
I'm trying to use logic to decide which array should be edited with destructuring, then passing the result back to a state. here's my code below. Thanks
Edit: I just fixed the code by adding an "=" sign instead of a ":". But this time, it is working halfway by adding a new value instead of modifying the existing array I'm trying to target with [eventId]
function toggleSelectedOption(event, id) {
let eventId = event.target.id
setSelectOption(prevState => {
return prevState.map((each, index) => {
if (index === id ) {
return [...each, each[eventId] = {...each[eventId], isSelected: !each[eventId].isSelected}]
}else {
return each;
}
})
})
}