Append and modify a flag onClick to Parent element if same element is present on Child element in react js

I want to modify a disabled flag to parent element which has same Id in child element and create a new array which is selected onClick.

let parent = [
{
    "title": "Create User",
    "id": "1",
    "level": 2,
    "child": [
        {
            "title": "View User",
            "id": "2",
            **"disabled": true,**
            "level": 3
        }
    ]
},
{
    "title": "View User",
    "id": "2",
    "disabled": false,
    "level": 2
},
{
    "title": "Toggle User",
    "id": "3",
    "level": 2,
    "child": [
        {
            "title": "View User",
            "id": "2",
            "disabled": true,
            "level": 3
        }
    ]
}

]

Lets suppose,

  1. I selected View User which is having id:”2″ only and nothing else. Disabled flag is “false” So it should allow to select
  2. I selected Create User with Id “1”, So child element also gets selected and Same id in level2 should be marked as disabled true. Because if user having create permission then it must have view permission.
  3. Again if user deselect Create user then parent element with view should be false, so that user can remove view permission.

I tried below code but it is working for Point 1, 2 but 3 is not working.

Note, currentItemId = “1” (Create User)
tempSubId = “2” (View User)

const updateProperty = (**parent**, currentItemId, tempSubId) => {
**parent**.forEach((item) => {
  if(tempSubId === item.id){
    item["disabled"] = !item.disabled
   }
  }
})

}

Any help would be appreciated.