How to reference a user related to entry input in if statement I am having trouble referencing a user in an if statement:

{% set otherEntry = craft.entries().section('other').userFieldInOtherEntry("{externalVariable}").one() %}

{% if currentUser is relatedTo(otherEntry) %}
    do something
{% endif %}


I've tried using the for loop method described in the Craft 3 documentation, but I get a recursive loop error.
You could do:

{% set otherEntry = craft.entries().section('other').userFieldInOtherEntry("{externalVariable}").one() %}

{% if currentUser in otherEntry.userFieldInOtherEntry %}
    do something
{% endif %}