In hook_form_alter(), how can I access the entity that is being flagged?
Ok, thanks to leymannx and No Sssweat, I think I finally understand how to get the entity from a form.
To get the entity being flagged inside a flag, this is what I had to do:
function MYMODULE_form_flagging_MYFLAG_add_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
      $flagging_entity = $form_state-&gt;getFormObject()-&gt;getEntity();
      $flagged_entity_id = $flagging_entity-&gt;get('entity_id')-&gt;value;
}