yup, if you feel like mutating X matters, feel free to do so
The main thing about the original data is you might need it for other purposes, so mutating that data is defying your ability to do that anywhere else in the code.
Mutating objects (arrays are objects) inside functions can lead to unexpected side-effects. It is usually better to make the change to a copy and return that new state out of the function. At least then you know what the data is at the function call site because it is what was returned.
In the flow of a large scale app, side-effects (mutations on references) performed inside functions can be harder to reason about as opposed to just return values.