# Issue 772: Conditional Approval Chain Display

## Problem

Record-detail approval history currently renders unreached approval steps as
`Upcoming` even when the approval process metadata says the step is conditional
and may be skipped or auto-approved when criteria do not match.

## Design

`ProcessDefinition.Metadata` remains the single source of truth for step
criteria and `ifCriteriaNotMet`. The fix does not add persisted
`ProcessNode` criteria columns and does not make record-detail pages query raw
metadata from the browser.

Backend Nexus mode exposes a record-scoped safe projection at:

`GET /services/data/v63.0/process/approvals/records/:recordId/step-display`

The endpoint:

- loads the latest `ProcessInstance` for the record;
- verifies the caller can read the target record, matching the existing summary
  endpoint authorization boundary;
- parses `ProcessDefinition.Metadata` server-side;
- returns only step identity/order and criteria-miss display facts:
  `processNodeId`, `stepOrder`, `stepName`, `stepLabel`,
  `hasEntryCriteria`, `ifCriteriaNotMet`;
- never returns raw metadata, formulas, boolean filters, criteria items, or
  criteria values.

The frontend treats this projection as transient display data. It enriches
`APIProcessNode` values with `metadata*` fields and then calls the pure
`buildApprovalChain` domain builder.

## Ordering Contract

Runtime `ProcessInstanceNode` rows are the primary audit sequence and remain in
`CreatedDate ASC` order. Definition-only placeholders are inserted into gaps
only when the builder can resolve a runtime row to a current definition order.

Resolution uses:

- current `ProcessNode.Id`;
- current `ProcessNode.Name` / `DeveloperName`;
- safe metadata aliases `stepName` / `stepLabel` from the backend projection.

This covers in-flight approvals whose old runtime rows were created from
rebuilt nodes using labels while current nodes were recreated by deploy sync
using developer names.

## Review Checks

- No browser-side `SELECT ... Metadata FROM ProcessDefinition` on
  record-detail approval history.
- Safe projection failure cannot collapse completed history/comments to summary
  fallback.
- Repeated runtime visits keep execution order.
- Skipped conditional placeholders stay in process order before later runtime
  nodes.
- Recreated `ProcessNodeId` rows resolve through metadata aliases, not only
  current node display fields.
