JS custom field in button card to check if location of a person is in list of defined zones

Looking for some help in the below which is to check if the location of a person is in already defined zones (friendly names). Please suggest.

custom_fields:
          loc: |
            [[[
              if (states["person.xxx"].state in [states | selectattr('domain', 'equalto', 'zone') | map(attribute='attributes.friendly_name') | list])
                return `<ha-icon
                  icon="mdi:map-marker"
                  style="width: 17px; height: 17px;">
                  </ha-icon>
                  <span> ${states['person.xxx'].state} </span>`
              else 
                return `<ha-icon
                  icon="mdi:map-export-outline" 
                  style="width: 17px; height: 17px;">
                  </ha-icon>
                  <span> ${states['person.xxx'].state} </span>`
            ]]]

Looks like you are checking to see if the person is in any defined zone.

If they are not in a zone, the state is not_home.

Check for that in your if statement and flip your if and else return statements.