Replica UNASSIGNED when primary goes down

Hello dear community, anyone can explain me what are the pre-conditions for replica to be assigned and promoted to primary? imagine a case we have 1 replica and 1 primary:

  1. we disable replica allocation
  2. we stop the node1 which had replica, replica gets unassigned
  3. we then start the node1 and stop node2 (node2 had primary)
  4. node1 did not have enough time to assign replica and now both replica/primary unassigned
  5. we enable replica allocation back

now what will happen? will replica be able to assign itself and promote itself to primary while original primary shard missing? “so in the time of primary shard getting unassigned replica was already unassigned”

I did some tests and seen cases where replica stuck and cant be assigned, we get explanation like:

{
  "index" : ".opensearch-sap-log-types-config",
  "shard" : 0,
  "primary" : false,
  "current_state" : "unassigned",
  "unassigned_info" : {
    "reason" : "REPLICA_ADDED",
    "at" : "2025-06-04T11:28:12.297Z",
    "last_allocation_status" : "no_attempt"
  },
  "can_allocate" : "no",
  "allocate_explanation" : "cannot allocate because allocation is not permitted to any of the nodes",
  "node_allocation_decisions" : [
    {
      "node_id" : "U6kMg0suSOKikSzN_vd5zA",
      "node_name" : "opensearch-master-2",
      "transport_address" : "10.233.95.221:9300",
      "node_attributes" : {
        "shard_indexing_pressure_enabled" : "true"
      },
      "node_decision" : "no",
      "deciders" : [
        {
          "decider" : "replica_after_primary_active",
          "decision" : "NO",
          "explanation" : "primary shard for this replica is not yet active"
        },
        {
          "decider" : "throttling",
          "decision" : "NO",
          "explanation" : "primary shard for this replica is not yet active"
        }
      ]
    },
    {
      "node_id" : "iwvvEfR5TUCTGkKqk37hlw",
      "node_name" : "opensearch-master-1",
      "transport_address" : "10.233.68.159:9300",
      "node_attributes" : {
        "shard_indexing_pressure_enabled" : "true"
      },
      "node_decision" : "no",
      "deciders" : [
        {
          "decider" : "replica_after_primary_active",
          "decision" : "NO",
          "explanation" : "primary shard for this replica is not yet active"
        },
        {
          "decider" : "throttling",
          "decision" : "NO",
          "explanation" : "primary shard for this replica is not yet active"
        }
      ]
    }
  ]
}