Passing null values to queries, Sprout Reports
Yes, the post you linked to is what you need to do.
I don't know where your settings variable is set so you may need to adjust a bit but something like this should get you started:
{# Start your element query #}
{% set query = craft
    .entries()
    .section('purchases')
%}

{# Check if settings.userId, if so, apply it to the query #}
{% if settings.userId %}
    {% set query = query.authorId(settings.userId) %}
{% endif %}

{# Run the query #}
{% set purchases = query.all() %}