Minecraft wiki entry for effect, associated text: In Java Edition, if a target already has a status effect with the same id, a new effect only with a longer duration or a higher amplifier can be added.
If the new effect has a higher amplifier and a shorter duration, the original effect will be hidden.
If the new effect has a lower amplifier and a longer duration, the new effect will be hidden.
If their "hideParticles" values are different, the active effect's value will be set to the specified value.
Otherwise, the original active effect will be replaced by the new effect, without changing hidden effects.
Only if the active effect is changed does the command succeed, no matter whether the hidden effects are changed or not.