Drupal - using form_state->set() inside ajax callback but cannot get the value back outside the callback
As 4k4 mentioned, you cannot change the form state inside an ajax callback function.
You can, however, change it in the ajax button submit function.
$form['ajax_button']['#submit'][] = [static::class, 'ajaxButtonSubmit'];
public static function ajaxButtonSubmit($form, $form_state) {
//...
}