The correct syntax is to not include Jinja delimiters ({{ ... }}
) as indicated by the warning. Your condition doesn’t work otherwise because the types are not compatible.
You could try type coercion:
when: 'item.id | string not in sh_vlan_id'
See: https://jinja.palletsprojects.com/en/3.1.x/templates/#builtin-filters