Add custom field in exposed form in view

Yes, the answer is correct, but not clear
You need to do so

/**
 * Implements hook_form_alter().
 */
function hayly_helper_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $query = Drupal::request()->query;
  $parent_category = $query->get('parent');
  
  if ($form_id == 'views_exposed_form') {
    $form('parent') = (
      '#type' => 'hidden',
      '#title' => t('Parent'),
      '#default_value' => $parent_category ?? '',
    );

    __hayly_insert_field_to_exposed_form($form, 'filter-parent', $parent_category, 0);
  }
}

function __hayly_insert_field_to_exposed_form(&$form, $field_key, $value, $insert_index) {
  // this value determines the position of the new element.
  $element_to_insert = array();
  $element_to_insert($field_key) = array(
    'value' => $value,
  );

  $form_info_top = array_slice($form('#info'), 0, $insert_index);
  $form_info_bottom = array_slice($form('#info'), $insert_index);
  $new_form_info = $form_info_top + $element_to_insert + $form_info_bottom;
  $form('#info') = $new_form_info;
}

If you have custom exposed filter twig – don’t forget to print your new field in your views-exposed-form.html.twig {{ form.parent }}
Also you can read this answer for more info