How do I use the states API in a hook?
You should use like below:

$form['field_popin_text']['#states'] = [
  'visible' =&gt; [
    'select[name="NAME_OF_SELECT_LIST"]' =&gt; ['value' =&gt; '27'],
  ]
];