Why does javascript does this?

I have the following function that a button triggers:

function handleRemoveItem (index) {
    const items = [...form[itemName]]
    items.splice(index, 1)
    console.log(items)
    //setForm({ ...form, [itemName]: items })
  }

The “itemName” is passed by another function, don’t worry about it.
I’m using react to create an app, the “items” constant looks like this when the function is triggered:

[
    0: {id: 8, productName: 'Product 1', stock: 20, expiration: '2025-07-01', lab: 2}
    1: {id: 2, productName: 'Product 2', stock: 7, expiration: '2024-08-01', lab: 3}
    2: {id: 15, productName: 'Product 3', stock: 4, expiration: '2024-09-01', lab: 2}
]

As you can see, each object has an id attribute. The function is used to remove an object from that array and works perfectly fine when the third line is comented but i need the React state updated to work with it.
So, Here is the problem:
When the third line is commented the object look like this (assume the index parametter is 1):

[
    0: {id: 8, productName: 'Product 1', stock: 20, expiration: '2025-07-01', lab: 2}
    1: {id: 15, productName: 'Product 3', stock: 4, expiration: '2024-09-01', lab: 2}
]

Perfectly fine, each objects remain intact but when i uncommented that line (so the state can be updated) it look like this:

[
    0: {id: 8, productName: 'Product 1', stock: 20, expiration: '2025-07-01', lab: 2}
    1: {productName: 'Product 3', stock: 4, expiration: '2024-09-01', lab: 2}
]

As you can see the id from the second object is missing, and i don’t know why, the code remains the same, only with that line uncommented, the console log it’s before the update state happends and throw me that array, the weird thing is only affected the forward objects for example if I remove the first object, the id attribute disapear for the next 2, but if I remove the last one the first 2 remains intact.

I tried a lot of things, I even ask chat gpt whats happening, I tried to use .map instead of splice but nothing works, not even with .filter, slice, I even tried to take all the id’s and put them together again and nothing works, I don’t know what I’m missing maybe a react thing that I’m not aware of, any ideas?