tag @e not working

im using tag @e[nbt={active_effects:[{id:"minecraft:unluck"}]}] add leeching_victim in a function, however the command just doesn't work when ran. Entities who clearly have the effect arent tagged when its ran, and i tested it with a command instead of a function and it works

idk 😭 im on 1.21.4

Continue to help post