All files / src/components/Merchants/MerchantPreview/helpers pahReassignment.ts

100% Statements 2/2
100% Branches 2/2
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                    30x     115x  
import { TPahReassignmentState } from "@components/Merchants/MerchantPreview/data.types";
 
/**
 * A PAH (Primary Account Holder) reassignment is "in flight" for the whole
 * window between the acquirer inviting the new PAH and the reassignment being
 * finalized (or declined). The BE (`owner_reassignment_state_view`) reports
 * `pending_reassignment` while the new PAH is still onboarding and flips to
 * `ready_for_approval` the moment their onboarding-person status reaches
 * `ready_for_verification` — under the approval-gated model the underlying
 * `owner_change_request` stays pending across both, so the reassignment is
 * still very much in flight. Any New-PAH UI (invite card, banner, upcoming-role
 * row) must stay visible across BOTH states; only the terminal/absent state
 * (`none` / undefined) hides it.
 *
 * Single source of truth for that check — consumed by the merchant side panel
 * (`PAHInfoSection`) and the Team-tab panel (`getPahPanelState`) so the two
 * cannot drift on which states count as in-flight.
 */
export const isPahReassignmentInFlight = (
  state?: TPahReassignmentState | null,
): boolean =>
  state === "pending_reassignment" || state === "ready_for_approval";