Checking if a value is in an array of IDS - using a filter? Is there an easier way to achieve this?
Perhaps using a |filter function?
{% set variantIds = [] %}
{% for variant in product.variants %}
  {% set variantId = variant.id %}
  {% set variantIds = variantIds|merge([variant.id]) %}
{% endfor %}

{% if wheelSpacer in variantIds %}
  this spacer
{% endif %}
You could use filter to get only the variant that matches the wheelSpacer variable. This will return an array, so you can use first to get the first matching variant (since presumably product.variants won't contain duplicate variants). This has the added benefit of getting you the matching variant directly, instead of it's ID:
{% set variant = product.variants|filter(variant =&gt; variant.id == wheelSpacer)|first %}
{% if variant %}
    {# ... #}
{% endif %}

As a sidenote, if your variants field is an Entries field, you'll want to use product.variants.all() instead.