Skip to content

[$250] Reports list Pay button (Web Chrome, ACH) unresponsive on first clicks; works only after page refresh #96068

Closed

Description

@MelvinBot

Action Performed:

  1. Go to Spend > Reports
  2. In the Reports list, click the Pay button on a reimbursable report row (ACH / VBBA payment)

Expected Result:

The first click dispatches the payment and the report is paid.

Actual Result:

The Pay button is unresponsive on the first (and often several subsequent) clicks — nothing happens. Reloading the page and clicking again eventually works. Users have to refresh and click multiple times until a pay finally goes through.

Platforms:

  • MacOS / Windows: Chrome (Web)

Root Cause Analysis

The Reports-list Pay button is a SettlementButton (PayActionCell) whose ability to dispatch a pay depends on live Onyx data — the IOU report, the chat report, the policy, and the VBBA bank-account list — none of which live in the search snapshot. On a fresh Reports-list load the row already shows "Pay" (that label comes from the snapshot), but the live data isn't hydrated yet, so early clicks either:

  • silently no-op — confirmPayment returns early when chatReport/reportID/hash/amount are missing (PayActionCell.tsx:81-84), or
  • fire without a bankAccountID, which the backend rejects.

A page refresh runs a full Onyx reload that hydrates the data, after which the same click works — exactly the "refresh and click multiple times" behavior reported.

Evidence chain

Client dispatch path (why early clicks do nothing):

Data-flow:

  1. Search snapshot loads → row shows "Pay" immediately.
  2. Live REPORT / POLICY / BANK_ACCOUNT_LIST collections not yet hydrated for the listed reports.
  3. User clicks Pay → confirmPayment early-returns (no chatReport) or dispatches without bankAccountID → backend rejects.
  4. User refreshes → OpenApp/ReconnectApp reloads Onyx → data hydrated → same click dispatches PayMoneyRequest with the bank account → success.

Proposed Fix

In the Reports-list row Pay path, gate the button on the required live Onyx data being loaded instead of letting it silently no-op:

  • Show a loading/disabled state (or block the press) while iouReport, chatReport, policy, and bankAccountList are still hydrating, so users can't click a button that will do nothing.
  • Ensure the ACH/VBBA bankAccountID is resolved before dispatching PayMoneyRequest.
  • Alternatively, seed the row's pay from the search snapshot (as the bulk path does) so the row Pay doesn't depend on lazily-loaded collections.

Related

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @lakchote

Activity

  1. ijmalik commented on Jul 14, 2026

    @ijmalik
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On the Reports list, the "Pay" button on an ACH/VBBA report row is unresponsive on first (and often several) clicks in Chrome — the click either silently no-ops or dispatches a payment without a valid bank account ID that the backend rejects. A page refresh resolves it.

    What is the root cause of that problem?

    The row renders "Pay" immediately from the Search snapshot's precomputed action field (ActionCell/index.tsx:86-98), but the payment logic in PayActionCell/SettlementButton reads iouReport (useReportWithTransactionsAndViolations, src/hooks/useReportWithTransactionsAndViolations.ts:19), policy (usePolicy.ts), and bankAccountList (useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST)) purely from live Onyx, with no fallback to snapshot data — unlike chatReport, which already falls back (ReportListItemHeader.tsx:277, chatReport = parentChatReport ?? snapshotChatReport). Concretely: while iouReport is undefined, isExpenseReportUtil(iouReport) returns false (ReportUtils.ts:1483-1486), so SettlementButton skips building the VBBA/business-bank-account option entirely (SettlementButton/index.tsx:321-349, gated on isExpenseReport); separately, even once iouReport/policy are correct, a still-unhydrated bankAccountList means the VBBA option can't be built with a valid bankAccountID, so the payment fires but is rejected server-side. A full reload hydrates all three collections and the button starts working.

    What changes do you think we should make in order to solve the problem?

    Split the fix by data source, since they aren't structurally equivalent:

    • iouReport and policy — I confirmed the Search snapshot already embeds full, untrimmed Report and Policy objects (src/types/onyx/SearchResults.ts:292-299: SearchResultDataType = PrefixedRecord<ONYXKEYS.COLLECTION.REPORT, Report> & PrefixedRecord<ONYXKEYS.COLLECTION.POLICY, Policy> & ...), keyed identically to live Onyx (report_${id}, policy_${id}) — the same shape chatReport already reads from. No backend change is needed: thread the snapshot's report/policy down through ActionCell → PayActionCell → SettlementButton and fall back (iouReport ?? snapshotReport, policy ?? snapshotPolicy) exactly like chatReport does today.
    • bankAccountList — this is a global, user-scoped key, not per-report, so it cannot come from the snapshot. Gate the button on it instead: while bankAccountList is undefined, show a loading/disabled state on the Pay button (mirroring the existing isDisabled={isOffline} convention already on KYCWall at SettlementButton/index.tsx:656) and block the press, so a click never fires without a resolvable bankAccountID.

    I could not find evidence that bankAccountList is proactively fetched at app boot (no reference in App.ts's OpenApp/ReconnectApp Onyx data, no loading flag for that key) — I'm not claiming this guard is a rare-case safety net; treat it as the primary gate until someone traces real Onyx state during a repro to confirm otherwise. If bankAccountList never resolves (fetch failure), the button stays disabled — the same open-ended limitation already shared by every other isOffline-gated button in this codebase, not a new failure mode introduced here.

    What alternative solutions did you explore? (Optional)

    Considered snapshot-fallback for bankAccountList too (to fully avoid any loading state) — rejected because it's a global collection with no per-row representation in the snapshot schema, so there's no data to fall back to. Also considered a blanket loading guard on all three collections instead of splitting the fix — rejected because iouReport/policy genuinely don't need it once the snapshot fallback is wired up, and gating on them anyway would reintroduce the refresh-like delay for data that's already available immediately.

  2. Gaohuilv commented on Jul 17, 2026

    @Gaohuilv

    !assign

  3. melvin-bot commented on Jul 17, 2026

    @melvin-bot

    📣 @Gaohuilv! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  4. added 2 commits that reference this issue on Jul 17, 2026
    f40e0d7
    a7e39ce
  5. Gaohuilv commented on Jul 17, 2026

    @Gaohuilv

    !assign

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 17, 2026
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 17, 2026
  8. melvin-bot commented on Jul 17, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External)

  9. KJ21-ENG commented on Jul 17, 2026

    @KJ21-ENG
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-17 15:18:34 UTC.

    Proposal

    What is the root cause of that problem?

    The Reports row is rendered inside the Search scope, so PayActionCell's own report and policy hooks are already snapshot-backed. The Search-aware useOnyx redirects only whitelisted keys such as REPORT and POLICY to the current snapshot; BANK_ACCOUNT_LIST is not whitelisted and therefore remains a live subscription.

    App/src/hooks/useOnyx.ts

    Lines 73 to 106 in 90ec1a9

    /**
    * Custom hook for accessing and subscribing to Onyx data with search snapshot support
    */
    const useOnyx: OriginalUseOnyx = <TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(key: TKey, options?: UseOnyxOptions<TKey, TReturnValue>, dependencies?: DependencyList) => {
    const isSnapshotCompatibleKey = !key.startsWith(ONYXKEYS.COLLECTION.SNAPSHOT) && CONST.SEARCH.SNAPSHOT_ONYX_KEYS.some((snapshotKey) => key.startsWith(snapshotKey));
    const isOnSearch = useIsOnSearch();
    let currentSearchHash: number | undefined;
    let shouldUseLiveData = false;
    if (isOnSearch && isSnapshotCompatibleKey) {
    const {currentSearchHash: searchContextCurrentSearchHash} = use(SearchQueryContext);
    const {shouldUseLiveData: contextShouldUseLiveData} = use(SearchResultsContext);
    currentSearchHash = searchContextCurrentSearchHash;
    shouldUseLiveData = !!contextShouldUseLiveData;
    }
    const useOnyxOptions = options as UseOnyxOptions<OnyxKey, OnyxValue<OnyxKey>> | undefined;
    const {selector: selectorProp, ...optionsWithoutSelector} = useOnyxOptions ?? {};
    // Determine if we should use snapshot data based on search state and key
    const shouldUseSnapshot = isOnSearch && !!currentSearchHash && isSnapshotCompatibleKey && !shouldUseLiveData;
    // Create selector function that handles both regular and snapshot data
    const selector = !selectorProp || !shouldUseSnapshot ? selectorProp : (data: OnyxValue<OnyxKey> | undefined) => selectorProp(getKeyData(data as SearchResults, key));
    const onyxOptions: UseOnyxOptions<OnyxKey, OnyxValue<OnyxKey>> = {...optionsWithoutSelector, selector};
    const snapshotKey = shouldUseSnapshot ? (`${ONYXKEYS.COLLECTION.SNAPSHOT}${currentSearchHash}` as OnyxKey) : key;
    const originalResult = originalUseOnyx(snapshotKey, onyxOptions, dependencies);
    // Extract the specific key data from snapshot if in search mode
    const result = resolveSnapshotAwareResult<TKey, TReturnValue>(shouldUseSnapshot, !!selector, originalResult, key);
    return result;

    App/src/CONST/index.ts

    Lines 7426 to 7434 in 90ec1a9

    SNAPSHOT_ONYX_KEYS: [
    ONYXKEYS.COLLECTION.REPORT,
    ONYXKEYS.COLLECTION.POLICY,
    ONYXKEYS.COLLECTION.TRANSACTION,
    ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
    ONYXKEYS.COLLECTION.REPORT_ACTIONS,
    ONYXKEYS.PERSONAL_DETAILS_LIST,
    ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
    ],

    The mismatch happens because PayActionCell can compute and display Pay from that snapshot-ready report/policy state, but it renders SettlementButton below SearchScopeProvider isOnSearch={false}. The nested button and KYC wall therefore build their payment choice from live policy/chat state and the live bank-account list. While those payment inputs are still loading, the short-form Pay control can have no concrete business-bank-account option or methodID, even though the snapshot row already looks actionable.

    function PayActionCell({isLoading, policyID, reportID, hash, amount, shouldDisablePointerEvents, chatReport}: PayActionCellProps) {
    const styles = useThemeStyles();
    const {convertToDisplayString} = useCurrencyListActions();
    const {isOffline} = useNetwork();
    const {isDelegateAccessRestricted} = useDelegateNoAccessState();
    const {showDelegateNoAccessModal} = useDelegateNoAccessActions();
    const [iouReport, transactions] = useReportWithTransactionsAndViolations(reportID);
    const policy = usePolicy(policyID);
    const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
    const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
    const [allReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS);
    const [reportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS);
    const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});
    const invoiceReceiverPolicyID = chatReport?.invoiceReceiver && 'policyID' in chatReport.invoiceReceiver ? chatReport.invoiceReceiver.policyID : undefined;
    const invoiceReceiverPolicy = usePolicy(invoiceReceiverPolicyID);
    const {
    currentUserLogin,
    currentUserAccountID,
    email,
    localCurrencyCode,
    introSelected,
    betas,
    isSelfTourViewed,
    userBillingGracePeriodEnds,
    amountOwed,
    ownerBillingGracePeriodEnd,
    activePolicyID,
    activePolicy,
    conciergeChat,
    defaultWorkspaceName,
    nextStep,
    chatReportPolicy,
    } = useReportPaymentContext({
    reportID,
    chatReportPolicyID: chatReport?.policyID,
    });
    const canBePaid = canIOUBePaid(iouReport, chatReport, policy, bankAccountList, currentUserLogin ?? '', currentUserAccountID, transactions, false, undefined, invoiceReceiverPolicy);
    const shouldOnlyShowElsewhere =
    !canBePaid && canIOUBePaid(iouReport, chatReport, policy, bankAccountList, currentUserLogin ?? '', currentUserAccountID, transactions, true, undefined, invoiceReceiverPolicy);
    const {currency} = iouReport ?? {};
    const confirmPayment = ({paymentType: type, payAsBusiness, methodID, paymentMethod}: PaymentActionParams) => {
    if (!type || !reportID || !hash || !amount || !chatReport) {

    return (
    <SearchScopeProvider isOnSearch={false}>
    <SettlementButton
    shouldUseShortForm
    size={CONST.BUTTON_SIZE.SMALL}
    currency={currency}
    formattedAmount={convertToDisplayString(Math.abs(getReimbursableTotal(iouReport)), currency)}
    policyID={policyID || iouReport?.policyID}
    iouReport={iouReport}
    chatReportID={iouReport?.chatReportID}
    enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS}
    onPress={confirmPayment}
    style={[styles.w100, shouldDisablePointerEvents && styles.pointerEventsNone]}
    wrapperStyle={[styles.w100]}
    shouldShowPersonalBankAccountOption={!policyID && !iouReport?.policyID}
    isDisabled={isOffline || shouldDisablePointerEvents}
    stayNormalOnDisable={shouldDisablePointerEvents}
    isLoading={isLoading}
    onlyShowPayElsewhere={shouldOnlyShowElsewhere}
    sentryLabel={CONST.SENTRY_LABEL.SEARCH.ACTION_CELL_PAY}
    />

    SettlementButton substitutes a generic business-bank-account option when no formatted account is available, while hydrated account options carry the concrete methodID. Its KYC wall also treats an expense report with no open connected account as needing account setup. Because the row does not distinguish "still loading" from "loaded with no account", an early press can be swallowed/diverted or reach payMoneyRequest without the VBBA bank-account ID. Refreshing hydrates the live payment state, so later presses work.

    const personalBankAccountList = getLatestPersonalBankAccount();
    const businessBankAccountOptionList = getBusinessBankAccountOptions(formattedPaymentMethods, currency);
    const businessBankAccountOptions =
    isExpenseReport && businessBankAccountOptionList.length
    ? businessBankAccountOptionList.map((account) => ({...account, value: CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT}))
    : undefined;
    const approveButtonOption: DropdownOption<string> = {
    text: translate('iou.approve', {formattedAmount}),
    icon: icons.ThumbsUp,
    value: CONST.IOU.REPORT_ACTION_TYPE.APPROVE,
    disabled: !!shouldDisableApproveButton,
    };
    const canUseWallet = !isExpenseReport && !isInvoiceReport && isCurrencySupportedForGlobalReimbursement(currency as CurrencyType);
    const canUseBusinessBankAccount = isExpenseReport || (isIOUReport(iouReport) && reportID && !hasRequestFromCurrentAccount(iouReport, accountID ?? CONST.DEFAULT_NUMBER_ID));
    const canUsePersonalBankAccount = shouldShowPersonalBankAccountOption || isIOUReport(iouReport);
    const isPersonalOnlyOption = canUsePersonalBankAccount && !canUseBusinessBankAccount;
    let paymentButtonOptions: Array<DropdownOption<string>>;
    // Only show the Approve button if the user cannot pay the expense
    if (shouldHidePaymentOptions && shouldShowApproveButton) {
    paymentButtonOptions = [approveButtonOption];
    } else if (onlyShowPayElsewhere) {
    paymentButtonOptions = [shouldUseShortForm ? shortFormPayElsewhereButton : paymentMethods[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]];
    } else {
    const buttonOptions: Array<DropdownOption<string>> = [];
    // To achieve the one tap pay experience we need to choose the correct payment type as default.
    if (canUseWallet) {
    if (personalBankAccountList.length && canUsePersonalBankAccount) {
    buttonOptions.push({
    text: translate('iou.settleWallet', ''),
    value: CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT,
    icon: icons.Wallet,
    });
    } else if (canUsePersonalBankAccount) {
    buttonOptions.push(paymentMethods[CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT]);
    }
    if (activeAdminPolicies.length === 0 && !isPersonalOnlyOption) {
    buttonOptions.push(paymentMethods[CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT]);
    }
    }
    const shouldShowBusinessBankAccountOptions = isExpenseReport && shouldShowPayWithExpensifyOption && !isPersonalOnlyOption;
    if (shouldShowBusinessBankAccountOptions) {
    if (businessBankAccountOptionList.length === 0) {
    buttonOptions.push(paymentMethods[CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT]);
    } else {
    for (const account of businessBankAccountOptionList) {
    buttonOptions.push({
    text: account.text,
    icon: typeof account.icon === 'number' ? icons.Bank : account.icon,
    additionalIconStyles: typeof account.icon === 'number' ? undefined : account.iconStyles,
    iconWidth: typeof account.icon === 'number' ? undefined : account.iconSize,
    iconHeight: typeof account.icon === 'number' ? undefined : account.iconSize,
    value: CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT,
    description: account.description,
    shouldIgnoreCompactStyle: true,
    onSelected: () => {
    if (checkForNecessaryAction(CONST.IOU.PAYMENT_TYPE.VBBA)) {
    return;
    }
    onPress({
    paymentType: CONST.IOU.PAYMENT_TYPE.VBBA,
    payAsBusiness: true,
    methodID: account.methodID,
    paymentMethod: CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT,
    });
    },
    });
    }
    }
    }

    const isExpenseReport = isExpenseReportReportUtils(iouReport);
    const paymentCardList = fundList ?? {};
    const hasOpenConnectedBusinessBankAccount = getOpenConnectedToPolicyBusinessBankAccounts(bankAccountList, policy).length > 0;
    const hasValidPaymentMethod = hasExpensifyPaymentMethod(paymentCardList, bankAccountList, shouldIncludeDebitCard);
    const isFromWalletPage = source === CONST.KYC_WALL_SOURCE.ENABLE_WALLET || source === CONST.KYC_WALL_SOURCE.TRANSFER_BALANCE;
    // Check if the user needs to add or select a payment method before continuing.
    // - For expense reports: Proceeds if no accounts that are connected are valid and usable (`OPEN`)
    // - For other expenses: Proceeds if the user lacks a valid personal bank account or debit card
    if ((isExpenseReport && !hasOpenConnectedBusinessBankAccount) || (!isExpenseReport && bankAccountList !== null && !hasValidPaymentMethod)) {
    Log.info('[KYC Wallet] User does not have valid payment method');
    if (!shouldIncludeDebitCard || (isFromWalletPage && !hasValidPaymentMethod)) {
    selectPaymentMethod(CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT, undefined, personalBankAccountOnSuccessFallbackRoute);
    return;
    }
    if (paymentMethod || policy) {
    setShouldShowAddPaymentMenu(false);
    selectPaymentMethod(paymentMethod, policy, personalBankAccountOnSuccessFallbackRoute);
    return;
    }
    if (iouPaymentType && isExpenseReport) {
    setShouldShowAddPaymentMenu(false);
    // Expense reports use a business bank account, so the personal bank account fallback route is not applicable.
    selectPaymentMethod(CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT);
    return;
    }
    const clickedElementLocation = getClickedTargetLocation(targetElement as HTMLDivElement);
    const position = getAnchorPosition(clickedElementLocation);
    setPositionAddPaymentMenu(position);
    setPendingPersonalBankAccountOnSuccessFallbackRoute(personalBankAccountOnSuccessFallbackRoute ?? null);
    setShouldShowAddPaymentMenu(true);
    return;

    The dispatch path makes the missing ID material: PayActionCell forwards only the selected methodID for VBBA, and payMoneyRequest uses that value as bankAccountID. The existing Search pay callback already demonstrates the correct fallback by using snapshotPolicy.achAccount.bankAccountID.

    payMoneyRequest({
    paymentType: type,
    chatReport,
    iouReport,
    introSelected,
    iouReportCurrentNextStepDeprecated: nextStep,
    currentUserAccountID,
    currentUserLogin: currentUserLogin ?? '',
    activePolicy,
    policy,
    chatReportPolicy,
    betas,
    isSelfTourViewed,
    userBillingGracePeriodEnds,
    amountOwed,
    ownerBillingGracePeriodEnd,
    methodID: type === CONST.IOU.PAYMENT_TYPE.VBBA ? methodID : undefined,
    additionalOnyxData,
    chatReportActions: allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(chatReport?.reportID)}`],

    if (!lastPolicyPaymentMethod || !Object.values(CONST.IOU.PAYMENT_TYPE).includes(lastPolicyPaymentMethod)) {
    goToItem();
    return;
    }
    if (lastPolicyPaymentMethod !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
    const hasVBBA = !!snapshotPolicy?.achAccount?.bankAccountID;
    if (!hasVBBA) {
    goToItem();
    return;
    }
    }
    const chatReportForPayment = getChatReportForSearchPay(chatReport, snapshotReport, searchData);
    if (!chatReportForPayment) {
    goToItem();
    return;
    }
    const chatReportPolicyForPayment = chatReportPolicy ?? getPolicyFromSearchSnapshot(chatReportForPayment.policyID, searchData, undefined);
    payMoneyRequest({
    paymentType: lastPolicyPaymentMethod,
    chatReport: chatReportForPayment,
    iouReport: snapshotReport,
    introSelected,
    iouReportCurrentNextStepDeprecated,
    currentUserAccountID: currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID,
    currentUserLogin: currentUserLogin ?? '',
    activePolicy,
    policy: snapshotPolicy ?? policy,
    chatReportPolicy: chatReportPolicyForPayment,
    betas,
    isSelfTourViewed,
    userBillingGracePeriodEnds,
    amountOwed,
    ownerBillingGracePeriodEnd,
    methodID: lastPolicyPaymentMethod === CONST.IOU.PAYMENT_TYPE.VBBA ? snapshotPolicy?.achAccount?.bankAccountID : undefined,
    additionalOnyxData: getSearchPayOnyxData(hash, item.reportID, currentSearchKey),

    What changes do you think we should make in order to solve the problem?

    Keep the fix local to the Reports-list Pay path. In PayActionCell, retain the result metadata from the existing BANK_ACCOUNT_LIST subscription and combine its loading status with the row's current loading state. While the live account list is loading, render SettlementButton as loading/disabled so a visible Pay control cannot accept a press before its payment options are resolvable. Gate on the subscription status, not on an empty value, because a loaded user with no bank account must still reach the existing KYC/setup flow.

    Do not add duplicate snapshot props for the IOU report and policy: those hooks already resolve through the surrounding Search scope. Also keep the inner live boundary rather than changing every nested SettlementButton subscription to the partial Search snapshot; this preserves the shared button's global workspace, invoice, and onboarding data behavior.

    When confirming a VBBA payment, resolve the bank-account ID as the selected option's methodID first and then the snapshot-backed policy's achAccount.bankAccountID, matching the existing Search pay callback. If the chat report or VBBA ID is still unavailable after loading, pass the existing row onButtonPress fallback into PayActionCell and open the report instead of silently returning or dispatching an incomplete request. Pay Elsewhere should continue without a bank-account ID.

    Test coverage: add a focused PayActionCell test under a Search scope with snapshot report/policy data. Verify a loading live bank-account subscription shows a non-actionable loading button and repeated presses issue no request; after hydration, verify the first press issues exactly one VBBA request with both the selected-ID path and policy-ID fallback. Also cover loaded-with-no-account routing to KYC/setup, missing chat/ID opening the report, Pay Elsewhere, and the existing header/deferred action-cell renderings.

    What alternative solutions did you explore? (Optional)

    I considered threading snapshot report/policy objects through every row and settlement call site, but those values are already snapshot-backed in PayActionCell, so that would duplicate the existing Search-aware hook behavior. I also considered removing the nested live-scope boundary; that would make collection-wide policy reads inside the shared settlement/KYC flow consume a partial Search snapshot, which has a larger and less predictable effect than gating the one live payment dependency and making the VBBA dispatch explicit.

  10. mukhrr commented on Jul 17, 2026

    @mukhrr
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-24 00:17:49 UTC.

    Proposal

    What is the root cause of that problem?

    The click never reaches the payment code. It is swallowed by the placeholder that DeferredActionCell renders in the Action column.

    The Reports-list row renders its Action cell through DeferredActionCell:

    [CONST.SEARCH.TABLE_COLUMNS.ACTION]: (
    <View style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.ACTION)]}>
    <ReportSubmitToPopoverMeasurableAnchor wrapperStyle={styles.w100}>
    <DeferredActionCell
    action={item.action}
    onButtonPress={onButtonPress}
    isSelected={isSelected}
    isLoading={isActionLoading}
    policyID={item.policyID}
    reportID={item.reportID}
    hash={item.hash}
    amount={item.total}
    chatReport={chatReport}
    isMarkAsDone={isMarkAsDone}
    shouldDisablePointerEvents={isPendingDelete || shouldDisableActionPointerEvents}
    />
    </ReportSubmitToPopoverMeasurableAnchor>
    </View>

    DeferredActionCell withholds the real ActionCell until a deferred value flips, and until then renders a stand-in Button:

    const shouldRender = useDeferredValue(true, false);
    if (!shouldRender) {
    const action = actionCellProps.action ?? CONST.SEARCH.ACTION_TYPES.VIEW;
    const shouldUseViewAction = action === CONST.SEARCH.ACTION_TYPES.VIEW || action === CONST.SEARCH.ACTION_TYPES.PAID || action === CONST.SEARCH.ACTION_TYPES.DONE;
    const isSuccess = !shouldUseViewAction && action !== CONST.SEARCH.ACTION_TYPES.UNDELETE;
    let text: string;
    if (shouldUseViewAction) {
    text = translate(actionTranslationsMap[CONST.SEARCH.ACTION_TYPES.VIEW]);
    } else {
    text = actionCellProps.isMarkAsDone ? translate('common.done') : translate(actionTranslationsMap[action]);
    }
    return (
    <Button
    text={text}
    small={!actionCellProps.extraSmall}
    extraSmall={actionCellProps.extraSmall}
    style={[styles.w100, styles.pointerEventsNone]}
    isDisabled
    success={isSuccess}
    isNested
    />
    );
    }

    That stand-in carries the real action label (Pay), the same success styling and the same width, but it is isDisabled with styles.pointerEventsNone. It is therefore indistinguishable from a live Pay button while being completely inert, so any press landing on it is silently dropped — no API call, no error, no loading state. Only once shouldRender flips does ActionCell mount the real PayActionCell:

    if (action === CONST.SEARCH.ACTION_TYPES.PAY) {
    return (
    <PayActionCell
    isLoading={isLoading}
    policyID={policyID}
    reportID={reportID}
    hash={hash}
    amount={amount}
    shouldDisablePointerEvents={shouldDisablePointerEvents}
    chatReport={chatReport}
    />
    );
    }

    The flip is driven by useDeferredValue(true, false), which schedules the reveal render on React's transition lane. Transition work yields to every competing higher-priority update, and the Search list produces those continuously (Onyx broadcasts for the search snapshot, report/policy collections, todos, Pusher pushes, row loading state). The inert window is therefore not a fixed frame — it grows with main-thread pressure, and it restarts on every page load. That is exactly the reported behaviour: press Pay, nothing happens; press again, nothing; refresh and keep trying until one press finally lands after the window has closed.

    Evidence (measured live on the Reports list, Chrome, local dev server)

    I sampled the Pay button's computed pointer-events every animation frame after a cold load, throttling the CPU through CDP to stand in for a heavier account:

    CPU throttle inert window
    1× 32 ms
    4× 196 ms
    10× 415 ms
    20× 1765 ms

    This is a one-row list, so it is the floor, not the ceiling.

    I then drove a real mouse click (not a synthetic dispatch) at the button's coordinates:

    • Click while the sampler reported pointer-events: none / opacity 0.5 → the payment menu did not open, nothing happened.
    • The next click, once the state had flipped to auto / opacity 1 → the menu opened with Pay with business account / Mark as paid.

    This also rules out "the live Onyx data has not hydrated yet" as the cause of the unresponsiveness: the failing click was at t = 952 ms and the succeeding one about 23 ms later. No report, policy or bank-account collection arrives in 23 ms — the only thing that changed is that the placeholder was replaced by the real cell. The boundary tracks the pointer-events flip exactly, and it moves with CPU throttling, which data hydration would not do.

    How the placeholder became indistinguishable from the real button

    The deferral originally rendered an honest skeleton (a PulsingView), which made the not-ready state obvious and did not invite a press. Commit eb8038d47ff replaced that skeleton with a disabled Button carrying the real action label, and commit efbf5ab16dc moved the reveal from useEffect + startTransition to useDeferredValue — both of which schedule on the interruptible transition lane. Together those two changes turned a visible skeleton into a convincing but dead button whose lifetime is unbounded.

    Because the guard lives in DeferredActionCell, this affects every row action in Search (Submit and Approve too), but Pay is the one where a dropped press costs the user a payment.

    What changes do you think we should make in order to solve the problem?

    The deferral itself is worth keeping — it keeps the expensive PayActionCell → SettlementButton → KYCWall subtree (dozens of Onyx subscriptions per row) out of the list's first paint. What must change is the lane the upgrade runs on, so the inert window is bounded by a single commit instead of by scheduler pressure.

    The repo already has the hook for precisely this hazard, and its doc comment names it:

    /**
    * Defers `active` from `false` to `true` until after navigation transitions finish, once `ready` becomes true.
    * Unlike `startTransition`/`useDeferredValue`, the update runs as a plain, synchronous render that can't be
    * interrupted and redone by a competing update.
    */
    function useRunAfterTransitions(ready: boolean): boolean {
    const [active, setActive] = useState(false);
    useEffect(() => {
    if (!ready) {
    return;
    }
    const handle = TransitionTracker.runAfterTransitions({
    callback: () => setActive(true),
    });
    return () => handle.cancel();
    }, [ready]);
    return active;
    }

    DeferredSearchAutocompleteList already adopted it for the same reason:

    // Wait for the slide-in animation to finish before rendering the list. With startTransition, a competing update
    // interrupted and discarded the (expensive) first mount render before it could commit, forcing React to redo
    // that same render a second time. useRunAfterTransitions fires a plain, synchronous update instead, so the first render always completes in a single pass.
    const shouldRender = useRunAfterTransitions(hasLayout);

    So the change in DeferredActionCell is to swap the primitive:

    +import useRunAfterTransitions from '@hooks/useRunAfterTransitions';
    -import React, {useDeferredValue} from 'react';
    +import React from 'react';
    
     function DeferredActionCell(actionCellProps: DeferredActionCellProps) {
    -    const shouldRender = useDeferredValue(true, false);
    +    const shouldRender = useRunAfterTransitions(true);

    This keeps the perf intent and improves on it in two ways. When a navigation transition is in flight (opening Spend → Reports), TransitionTracker holds the heavy cell back until the animation ends, which is exactly when we want to mount it. When no transition is active, the callback fires synchronously inside the mount effect, so the upgrade lands as a plain, uninterruptible update on the very next render pass rather than whenever the scheduler has a free moment.

    I verified this red → green in the browser. Re-running the same frame-by-frame sampler after the change, the sampler never observes an inert state at any throttle level — the button is pointer-events: auto from its first sampled paint at 1×, 4×, 10× and 20×. At 10× CPU throttling (which previously produced a 415 ms inert window) the first real mouse click opens the payment menu.

    For regression cover I added tests/unit/DeferredActionCellTest.tsx, which asserts that the cell upgrades to the pressable action cell so the first press dispatches, and that the upgrade is driven by TransitionTracker rather than an interruptible transition. The second test fails on current main (the transition-lane reveal mounts the real cell regardless of the tracker) and passes with the fix.

    What alternative solutions did you explore? (Optional)

    Restoring the original skeleton placeholder would make the not-ready state honest again, so users would not aim at a dead control. It does not close the window though — the press is still lost — and it reverts a deliberate visual decision.

    Having the placeholder capture the press and replay it once the real cell mounts would be airtight, but replaying into SettlementButton means programmatically reopening its dropdown, which is far more machinery than this bug warrants.

    Dropping the deferral entirely would fix it too, but it puts the full SettlementButton + KYCWall subtree of every visible row back into the list's first paint, which is the cost the deferral exists to avoid.

    I also checked the theory that the press reaches confirmPayment and early-returns on un-hydrated live Onyx data. The 23 ms gap between the failing and succeeding click, and the fact that the window scales with CPU throttling, rule that out as the cause of the unresponsiveness. Whether row Pay should additionally fall back to policy.achAccount.bankAccountID when methodID is absent is a separate question about the payment parameters, not about the button being dead, and is better handled on its own issue.

    96068-before.mp4
    96068-after.mp4
  11. 22 remaining items

  12. DylanDylann commented on Jul 27, 2026

    @DylanDylann
    Contributor

    Actually, I think we should do nothing here. Setting CPU throttling to 6× or 20× slowdown to reproduce this doesn't make sense to me, because at that level of throttling, there are lots of similar bugs across our app

  13. lorretheboy commented on Jul 27, 2026

    @lorretheboy
    Contributor

    @DylanDylann I think we have to reduce the performance since our testing device is pretty strong compared to QA's one

  14. DylanDylann commented on Jul 28, 2026

    @DylanDylann
    Contributor

    Hi @mountiny, what are your thoughts on bugs that require lowering the CPU to reproduce? Should we fix them?

  15. mountiny commented on Jul 28, 2026

    @mountiny
    Contributor

    Yes, lots of our customer are using low end windows devices so we need to focus on these too

  16. emkhalid commented on Jul 28, 2026

    @emkhalid
    Contributor

    @DylanDylann I reproduced the bug on 4x CPU throttling. Videos are in my updated proposal — please check it when you get a chance.

  17. DylanDylann commented on Jul 30, 2026

    @DylanDylann
    Contributor

    The Pay button is already disabled, so its unresponsiveness should be intentional, not a bug. Because we're using DeferredActionCell here (see #89083 for an explanation of why we need it). Tbh, I'd still vote to close this issue.

    🎀👀🎀 C+ reviewed

  18. melvin-bot commented on Jul 30, 2026

    @melvin-bot

    Triggered auto assignment to @lakchote, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  19. DylanDylann commented on Jul 30, 2026

    @DylanDylann
    Contributor

    That said, I'd love to keep this discussion open to hear more thoughts, especially from anyone who has an idea that could add real value here. Thank you guys

  20. emkhalid commented on Jul 30, 2026

    @emkhalid
    Contributor

    @DylanDylann I understand that the Pay button is intentionally disabled while loading. However, clicking it opens the report underneath instead of doing nothing. A disabled button should not trigger a different action, as shown in my video.

    Screencast.From.2026-07-29.01-56-32.mp4
  21. lakchote commented on Jul 30, 2026

    @lakchote
    Contributor

    The Pay button is already disabled, so its unresponsiveness should be intentional, not a bug. Because we're using DeferredActionCell here (see #89083 for an explanation of why we need it). Tbh, I'd still vote to close this issue.

    🎀👀🎀 C+ reviewed

    @trjExpensify what your thoughts here?

  22. DylanDylann commented on Jul 31, 2026

    @DylanDylann
    Contributor

    Let me elaborate on the problem in more detail. In the video below, I set the CPU throttling to 20x slower to slow things down. When going to the report page, the action button is initially disabled. This is intentional, because we need a heavy computation to render the action button(as I recall, we need to get lots of information to compute all options to pay --> heavy computation). So to avoid impacting the page render, we decided to render the page first and defer rendering the action button by disabling it initially, only enabling it once it's ready.

    Screen.Recording.2026-07-31.at.11.53.30.mov
  23. lakchote commented on Jul 31, 2026

    @lakchote
    Contributor

    Thanks for the details @DylanDylann, your explanation makes sense to me. Let's close the issue and put our focus elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions