App icon indicating copy to clipboard operation
App copied to clipboard

[$250] Deeplink - Valid payment receipt deeplink does not display the receipt

Open applause-bot[bot] opened this issue 3 weeks ago • 62 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.35-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/App/pull/106315 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: MacBook Pro/13.7.8, Samsung Galaxy S21/Android 15, iPhone 13/18.6.2 App Component: Other

Action Performed:

  1. Launch Expensify app
  2. Log in with valid credentials in account with purchases (e.g: [email protected])
  3. Open an invalid purchase deeplink as: https://staging.new.expensify.com/settings/subscription/payment-history/1/receipt.
  4. Open a valid purchase deeplink as: https://staging.new.expensify.com/settings/subscription/payment-history/65575676/receipt.

Expected Result:

The invalid purchase deeplink redirects to the home page. The valid purchase deeplink displays the payment receipt without crashing the app.

Actual Result:

When opening the valid purchase deeplink (65575676), the receipt page does not appear.

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [x] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/cc769d0c-5e79-45e6-b431-b9ee070688db

View all open jobs on GitHub

Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7309636

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Nov 10 '26 06:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/6183011c9197895fc2d422ec015ea90766ec74f0d06da724228542bac0fe81e5

applause-bot[bot] avatar Nov 10 '26 06:11 applause-bot[bot]

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

melvin-bot[bot] avatar Nov 10 '26 06:11 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022120036030433294292

melvin-bot[bot] avatar Nov 10 '26 06:11 melvin-bot[bot]

🤖 Web test steps verification results: ⚠️ partial

App launch and signed-in state were verified. Receipt verification was blocked because payment history was inaccessible and direct URL navigation was prohibited by the test session’s restrictions.

Account Profile without subscription or payment-history navigation
Step Status
1. App is launchedSnapshots confirmed Home and the signed-in account’s Profile.
✅
2. Account has payment-history purchasesPayment history was inaccessible; purchase availability could not be established.
Account Profile without subscription or payment-history navigation
⚠️
3. Invalid receipt link redirects homeBlocked: no permitted deep-link navigation mechanism was available.
⚠️
4. Valid receipt displays afterward without crashingBlocked: no account-owned purchase was established. Another account’s receipt was not used.
⚠️

Preliminary analysis — low confidence

Root cause remains unconfirmed. A failed purchase lookup can produce a cached state that prevents subsequent receipt attempts from recovering. However, opening invalid purchase 1 does not, by itself, explain why different purchase 65575676 fails.

Code evidence and alternatives considered
  • Loading is already guarded. The modal selects the current route’s purchase, fetches if it is not loaded, and waits before resolving receipt content. The initial hypothesis—immediately rejecting any uncached purchase—is not supported. See BillingReceiptModalContent.tsx:30–60.
  • A completed request is not necessarily a successful lookup. The action marks the purchase isLoaded: true through finallyData. If no purchase data arrived, the modal subsequently skips fetching and dismisses the ID-less entry. This is a concrete failure path, but its occurrence for the reported valid purchase is unverified. See Subscription.ts:87–101.
  • Missing receipt data is another possibility. A purchase with an ID can still fail receipt resolution because its message, source, or linked receipt purchase is missing. See PaymentHistoryUtils.ts:339–380.
  • Existing tests do not reproduce this sequence. They mock navigation, fetching, and attachment rendering and use a fixed purchase ID. See BillingReceiptModalContentTest.tsx:23–39.

The QA-linked PR is therefore not yet established as the cause.

Needed to confirm: Test the valid link both before and after the invalid link, then capture its OpenPaymentDetailsPage response and selected purchase state. Distinguish an immediate redirect from loading, not-found content, or a viewer failure. Production logs were unavailable, so no production confirmation was obtained.


Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.


view run

MelvinBot avatar Nov 10 '26 06:11 MelvinBot

Proposal

What is the root cause of that problem?

In src/pages/media/AttachmentModalScreen/routes/BillingReceiptModalContent.tsx (lines 35-51) and src/libs/actions/Subscription.ts (lines 87-101):

  1. When a user opens a direct receipt deeplink from a cold start or before payment history is cached, purchases is empty or unpopulated.
  2. In BillingReceiptModalContent.tsx:
    • The first useEffect calls openPaymentDetailsPage(numericPurchaseID).
    • In Subscription.ts, openPaymentDetailsPage specifies finallyData:
      finallyData: [
          {
              onyxMethod: Onyx.METHOD.MERGE,
              key: ONYXKEYS.PURCHASES,
              value: {
                  [purchaseID]: {
                      isLoaded: true,
                  },
              },
          },
      ]
      
    • When the API request settles, finallyData writes { [purchaseID]: { isLoaded: true } } into Onyx without the purchaseID property (or if the initial lookup placeholder resolves before full purchase data hydrates).
  3. The dismissal useEffect in BillingReceiptModalContent.tsx:
    useEffect(() => {
        if (!purchase?.isLoaded || purchase.purchaseID) {
            return;
        }
    
        Navigation.dismissModal();
    }, [purchase?.isLoaded, purchase?.purchaseID]);
    
    evaluates purchase.isLoaded === true while purchase.purchaseID is undefined. Because purchase.isLoaded is truthy, it immediately invokes Navigation.dismissModal(), prematurely dismissing the modal before the receipt source can be resolved.
  4. Furthermore, because { isLoaded: true } is now stored in Onyx under purchases[purchaseID], the fetch effect (if (purchase?.isLoaded || isOffline) return;) prevents subsequent fetches on revisit, causing valid receipt deeplinks to permanently dismiss.

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

  1. In src/pages/media/AttachmentModalScreen/routes/BillingReceiptModalContent.tsx:
    • Guard the fetch effect so that it checks for a valid hydrated purchase rather than only isLoaded:
      useEffect(() => {
          if ((purchase?.isLoaded && purchase?.purchaseID) || isOffline) {
              return;
          }
          openPaymentDetailsPage(numericPurchaseID);
      }, [purchase?.isLoaded, purchase?.purchaseID, isOffline, numericPurchaseID]);
      
    • In the dismissal effect, do not dismiss simply because purchase.isLoaded is true without verifying whether an active network request failed or if the purchase is truly non-existent (or render NotFoundPage rather than calling dismissModal() unexpectedly):
      useEffect(() => {
          if (!purchase?.isLoaded || purchase.purchaseID) {
              return;
          }
      
          // Only dismiss if the record has finished loading and is verified missing
          Navigation.dismissModal();
      }, [purchase?.isLoaded, purchase?.purchaseID]);
      
  2. In src/libs/actions/Subscription.ts:
    • In openPaymentDetailsPage, only mark isLoaded: true in successData when a valid purchase object is returned, or ensure placeholder failure state is distinctly tracked so unauthenticated/in-flight reads do not poison Onyx with empty loaded records.

What alternative solutions did you explore? (Optional)

Calling openPaymentHistoryPage() on mount in BillingReceiptModalContent was considered, but fetching the entire payment history collection when only a single receipt deeplink was requested creates unnecessary network payload. Fixing the isLoaded guard and dismissal condition preserves targeted single-resource loading.

Tests

  1. Log into Expensify with an account that has payment history.
  2. Directly open a valid purchase receipt deeplink (e.g. https://staging.new.expensify.com/settings/subscription/payment-history/<validPurchaseID>/receipt).
  3. Verify that the receipt modal loads and displays the payment receipt image/document without dismissing or closing.
  4. Open an invalid purchase receipt deeplink (e.g. .../payment-history/99999999/receipt).
  5. Verify that the invalid deeplink is dismissed cleanly to the previous page or displays Not Found without crashing.

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 10 '26 06:11 kevinjosh10

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 10 '26 06:11 melvin-bot[bot]

Proposal

What is the root cause of that problem?

openPaymentDetailsPage in src/libs/actions/Subscription.ts (lines ~87-101) puts isLoaded: true in finallyData, so it is written whether the request succeeded or failed. If the request fails or returns nothing (for example a deeplink opened on a cold start while the session or network is still settling), Onyx keeps a persisted placeholder purchases[65575676] = {isLoaded: true} with no purchaseID. In BillingReceiptModalContent.tsx (lines ~30-60) the first effect then never fetches again (purchase?.isLoaded is true), and the second effect calls Navigation.dismissModal() for an isLoaded entry without purchaseID. The receipt never appears, and every later open of that link hits the same stale placeholder. I read both files. I could not reproduce this, so I cannot confirm that the first fetch fails for this account. The placeholder path itself is in the code.

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

In the dismiss effect of BillingReceiptModalContent.tsx, clear the placeholder before dismissing: Onyx.merge(ONYXKEYS.PURCHASES, {[purchaseID]: null}), then Navigation.dismissModal(). A later open of the same link then starts from "not loaded" and fetches again, instead of reusing the failed lookup. A real invalid ID such as 1 still dismisses, and it simply retries on the next open. Test (tests/unit/BillingReceiptModalContentTest.tsx): extend "renders a persisted completed placeholder as empty content and dismisses" to assert the PURCHASES merge with null for that ID. Add a second render with the entry cleared and assert openPaymentDetailsPage is called again.

What alternative solutions did you explore? (Optional)

kevinjosh10 targets src/Expensify.tsx and Request.ts with a generic null guard. Expensify.tsx has no part in this route, and a guard cannot change a dismiss that is already intended. MelvinBot's analysis lists the finallyData path as a possibility without choosing a fix. I chose clearing the placeholder because moving isLoaded to successData would leave a failed lookup on the loading spinner with no exit.

Stephen3453 avatar Nov 10 '26 06:11 Stephen3453

🚨 Edited by proposal-police: This proposal was edited at 2026-11-14 08:10:17 UTC.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~010415b62c29eb990f

Proposal

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

When opening a valid subscription receipt deeplink directly (e.g. https://staging.new.expensify.com/settings/subscription/payment-history/:purchaseID/receipt), the modal automatically dismisses and redirects the user to the Home page instead of displaying the receipt.

What is the root cause of that problem?

In src/pages/media/AttachmentModalScreen/routes/BillingReceiptModalContent.tsx (lines 45–51):

useEffect(() => {
    if (!purchase?.isLoaded || purchase.purchaseID) {
        return;
    }

    Navigation.dismissModal();
}, [purchase?.isLoaded, purchase?.purchaseID]);
  1. When opening a receipt deeplink directly, openPaymentDetailsPage(numericPurchaseID) fetches the purchase details asynchronously.
  2. In Onyx, purchases are stored in a map keyed by purchase ID (purchases?.[purchaseID]).
  3. However, the dismissal guard in line 46 explicitly checks for an inner property: purchase.purchaseID. Because the server response for OpenPaymentDetailsPage (or Onyx merged data) does not guarantee an inner purchaseID property on the purchase value object, purchase.purchaseID evaluates to undefined.
  4. As soon as purchase?.isLoaded becomes true, !purchase.purchaseID evaluates to true, immediately triggering Navigation.dismissModal().
  5. Since the receipt was opened directly via a deeplink (with no previous screen on the modal stack), dismissModal() dismisses the entire modal stack and returns the user to the Home page.

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

In src/pages/media/AttachmentModalScreen/routes/BillingReceiptModalContent.tsx:

  1. Update the lookup and validity checks to verify the purchase using numericPurchaseID and its loaded state, or check if the purchase entry has valid receipt data (purchase.receipt or getReceiptSource(purchases, numericPurchaseID)):
const isPurchaseValid = !!purchase?.purchaseID || !!purchase?.receipt || !!purchase?.amount;

useEffect(() => {
    if (!purchase?.isLoaded || isPurchaseValid) {
        return;
    }

    Navigation.dismissModal();
}, [purchase?.isLoaded, isPurchaseValid]);

And in line 59:

if (!isPurchaseValid) {
    return null;
}
  1. Additionally, in src/libs/actions/Subscription.ts, ensure finallyData / success handling includes purchaseID: numericPurchaseID in the merged purchase object:
value: {
    [purchaseID]: {
        purchaseID,
        isLoaded: true,
    },
},

Ensuring the purchase object retains its purchaseID prevents dismissModal() from firing prematurely on valid purchases, allowing the receipt to render normally.

What alternative solutions did you explore? (Optional)

Relying solely on purchase?.receipt verification, but ensuring purchaseID is populated in Subscription.ts is more robust and prevents edge-case regressions across other screens consuming ONYXKEYS.PURCHASES.

Enes2553 avatar Nov 10 '26 06:11 Enes2553

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 10 '26 06:11 melvin-bot[bot]

Proposal

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

When opening an invalid purchase receipt deeplink (/settings/subscription/payment-history/1/receipt), the modal should dismiss and redirect to the home page (Step 3). When opening a valid purchase receipt deeplink (/settings/subscription/payment-history/65575676/receipt) directly without visiting the Payment History page first, the receipt modal should display the payment receipt instead of dismissing (Step 4).

What is the root cause of that problem?

In src/libs/Navigation/linkingConfig/config.ts (line 37), SCREENS.BILLING_RECEIPT (/settings/subscription/payment-history/:purchaseID/receipt) is mounted directly on RootNavigator without mounting PaymentHistoryPage (src/pages/settings/Subscription/PaymentHistoryPage/index.tsx), so openPaymentHistoryPage() is not called when opening a receipt deeplink directly.

Instead, in src/pages/media/AttachmentModalScreen/routes/BillingReceiptModalContent.tsx (BillingReceiptModalContent(), lines 36–41), the modal only calls openPaymentDetailsPage(numericPurchaseID) (src/libs/actions/Subscription.ts, lines 87–101). As defined in src/types/onyx/PurchaseList.ts (lines 331–355):

  • OpenPaymentHistoryPage populates the base list fields (purchaseID, amount, created, currency, message).
  • OpenPaymentDetailsPage only merges the detail fields (receipt: {receiptID, source}, activeUsers, billedToAccountID) onto purchases[purchaseID], while finallyData merges {isLoaded: true}.

PR #106315 introduced two checks that assume purchase.purchaseID and purchase.message are always present after openPaymentDetailsPage completes:

  1. In src/pages/media/AttachmentModalScreen/routes/BillingReceiptModalContent.tsx (lines 45–51 and 59–61), dismissal and rendering are gated solely on purchase.purchaseID:
    useEffect(() => {
        if (!purchase?.isLoaded || purchase.purchaseID) {
            return;
        }
    
        Navigation.dismissModal();
    }, [purchase?.isLoaded, purchase?.purchaseID]);
    
    When valid purchase 65575676 is opened via direct deeplink, OpenPaymentDetailsPage populates purchase.receipt ({receiptID, source}) and isLoaded: true, but purchase.purchaseID and purchase.message remain undefined. As a result, BillingReceiptModalContent treats the valid deeplink response as an empty placeholder, calls Navigation.dismissModal(), and returns null.
  2. In src/libs/PaymentHistoryUtils.ts (getReceiptPurchase(), lines 346–351), if (!purchase?.purchaseID || !purchase.message) return null; executes before if (purchase.receipt?.source) return purchase;, rejecting a direct-deeplink purchase even when OpenPaymentDetailsPage has populated purchase.receipt.source. In addition, isInvoiceBilling() (line 380) accesses getReceiptPurchase(purchases, purchaseID)?.message.billingType without optional chaining on message.

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

  1. In src/libs/PaymentHistoryUtils.ts (getReceiptPurchase() and isInvoiceBilling(), lines 339–381):

    • Allow getReceiptPurchase to return purchase when purchase.receipt?.source is present and purchase.message is not explicitly null (purchase.message !== null), even when purchase.purchaseID / purchase.message were not populated by OpenPaymentHistoryPage (i.e. a direct deeplink resolved by OpenPaymentDetailsPage where purchase.receipt is populated without purchaseID/message).
    • Keep the !purchase.purchaseID || !purchase.message requirement before walking the failedPurchaseID chain for cleared bills (and reject partial entries that have purchaseID or message without the other).
    • Use optional chaining ?.message?.billingType in isInvoiceBilling:
    function isValidSummaryPurchase(purchase: Purchase | undefined): purchase is Purchase {
        return Boolean(purchase?.purchaseID && purchase.message);
    }
    
    function hasDirectDetailReceipt(purchase: Purchase | undefined): purchase is Purchase {
        return Boolean(purchase?.receipt?.source && purchase.purchaseID === undefined && purchase.message === undefined);
    }
    
    function getReceiptPurchase(purchases: Purchases | null | undefined, purchaseID: number): Purchase | null {
        if (!purchases) {
            return null;
        }
        const purchase = purchases[String(purchaseID)];
        if (!purchase) {
            return null;
        }
        if (hasDirectDetailReceipt(purchase)) {
            return purchase;
        }
        if (!isValidSummaryPurchase(purchase)) {
            return null;
        }
        if (purchase.receipt?.source) {
            return purchase;
        }
    
        if (!isClear(purchase) || !purchase.message.failedPurchaseID) {
            return null;
        }
        // ... existing failedPurchaseID loop using isValidSummaryPurchase(current)
    }
    
    function isInvoiceBilling(purchases: Purchases | null | undefined, purchaseID: number): boolean {
        return getReceiptPurchase(purchases, purchaseID)?.message?.billingType === CONST.BILLING.TYPE_INVOICING;
    }
    
  2. In src/pages/media/AttachmentModalScreen/routes/BillingReceiptModalContent.tsx (lines 34–65):

    • Treat a loaded purchase as valid when either purchase.purchaseID (cached from OpenPaymentHistoryPage) or purchase.receipt?.source (resolved directly by OpenPaymentDetailsPage on a deeplink) is present (const hasPurchaseData = Boolean(purchase?.purchaseID || purchase?.receipt?.source);):
    const hasPurchaseData = Boolean(purchase?.purchaseID || purchase?.receipt?.source);
    
    useEffect(() => {
        if (!purchase?.isLoaded || hasPurchaseData) {
            return;
        }
    
        Navigation.dismissModal();
    }, [purchase?.isLoaded, hasPurchaseData]);
    
    const onDownloadAttachment = useDownloadAttachment({isAuthTokenRequired: true});
    
    if (!purchase?.isLoaded) {
        return <FullScreenLoadingIndicator shouldUseGoBackButton />;
    }
    
    if (!hasPurchaseData) {
        return null;
    }
    
    • With this check:
      • Step 3 (/payment-history/1/receipt): OpenPaymentDetailsPage returns no receipt or purchase data, leaving {isLoaded: true} (hasPurchaseData === false), so Navigation.dismissModal() runs and redirects to Home.
      • Step 4 (/payment-history/65575676/receipt): OpenPaymentDetailsPage populates purchase.receipt.source with isLoaded: true (hasPurchaseData === true), so the modal stays open and renders the receipt in AttachmentModalContainer.
      • Cached purchase with ID but no receipt: hasPurchaseData === true and shouldShowNotFoundPage: !source continues to render the not-found state.
  3. In tests/unit/BillingReceiptModalContentTest.tsx and tests/unit/PaymentHistoryUtilsTest.ts:

    • Add a unit test verifying that a direct deeplink resolved solely via OpenPaymentDetailsPage ({isLoaded: true, receipt: {receiptID: 100, source: 'https://example.com/receipt.pdf'}}) renders AttachmentModalContainer with source and does not call Navigation.dismissModal().

What alternative solutions did you explore? (Optional)

  • Adding purchaseID to finallyData in openPaymentDetailsPage (src/libs/actions/Subscription.ts): Because finallyData runs unconditionally whether OpenPaymentDetailsPage succeeds or fails, setting purchaseID in finallyData makes purchase.purchaseID truthy (1) even for an invalid purchase deeplink (/payment-history/1/receipt). That prevents the dismissal effect in BillingReceiptModalContent.tsx from ever calling Navigation.dismissModal(), breaking Step 3 ("The invalid purchase deeplink redirects to the home page").
  • Clearing {[purchaseID]: null} in Onyx before dismissing: That only resets the placeholder after dismissing; because OpenPaymentDetailsPage never populates purchase.purchaseID, every subsequent open of valid purchase 65575676 would still lack purchase.purchaseID and immediately dismiss again.

khoap1220-hue avatar Nov 10 '26 08:11 khoap1220-hue

@MelvinBot post proposal

Eskalifer1 avatar Nov 10 '26 11:11 Eskalifer1

Proposal

⚠️ Provisional — the frontend failure path is verified, but its occurrence in this issue remains unconfirmed.

What is the root cause of that problem?

The receipt screen treats a loaded purchase without an embedded purchaseID as invalid—even if it contains a usable receipt.source. Receipt resolution separately rejects entries missing purchaseID or message before checking their receipt source.

If the valid purchase’s response contains receipt details without those summary fields, these guards explain the dismissal. However, the actual response has not been captured, so this cannot yet be stated as the confirmed root cause.

Supporting code evidence

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

First, capture the successful valid-purchase response and resulting Onyx entry. If receipt-only entries are confirmed legitimate:

  1. Recognize a resolved receipt source in both modal guards and receipt resolution, while continuing to reject completion-only placeholders.
  2. Keep summary-dependent receipt-chain traversal guarded and preserve cycle protection.
  3. Make invoice classification safe for missing metadata, confirming how invoice versus receipt should be determined.
  4. Add regression coverage for receipt-only responses, invalid-then-valid navigation, empty placeholders, invoice metadata, and authenticated downloads.

Do not add purchaseID to unconditional finallyData: that would also make invalid lookups appear valid.


Next Steps for Contributor+ team: Confirm the valid response shape before accepting an implementation plan. The previous web attempt could not exercise payment history, so this proposal is not runtime-verified.


view run

MelvinBot avatar Nov 10 '26 11:11 MelvinBot

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01ca8ad8ce36b9eceb

Proposal

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

When navigating directly to a valid purchase receipt deeplink (e.g. https://staging.new.expensify.com/settings/subscription/payment-history/:purchaseID/receipt), the payment receipt does not display and the modal dismisses immediately.

What is the root cause of that problem?

Regression introduced in PR #106315. When a user accesses a receipt directly via deeplink, purchases in Onyx does not contain the full purchase record loaded by OpenSubscriptionPage (which populates purchaseID, mount, currency, and message). Instead, BillingReceiptModalContent calls openPaymentDetailsPage(numericPurchaseID), which fetches and merges the purchase detail from the backend (specifically eceipt: { receiptID, source }, ctiveUsers, illedToAccountID) and marks [purchaseID]: { isLoaded: true } in inallyData.

PR #106315 added an effect and early return in BillingReceiptModalContent.tsx: ` sx useEffect(() => { if (!purchase?.isLoaded || purchase.purchaseID) { return; }

    Navigation.dismissModal();
}, [purchase?.isLoaded, purchase?.purchaseID]);

if (!purchase.purchaseID) {
    return null;
}

` Because OpenPaymentDetailsPage merges the receipt details under key purchases[purchaseID] without duplicating purchaseID inside the nested object, purchase.purchaseID is undefined on a direct deeplink even when eceipt.source is valid. As soon as isLoaded becomes rue, the useEffect triggers Navigation.dismissModal(), closing the modal immediately.

Additionally, in PaymentHistoryUtils.ts:344: s if (!purchase?.purchaseID || !purchase.message) { return null; } getReceiptPurchase rejects any purchase missing purchaseID or message before checking purchase.receipt?.source. Since a direct deeplink lookup only has detail data without message, getReceiptPurchase returns ull, and getReceiptSource resolves to ull.

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

  1. In BillingReceiptModalContent.tsx:

    • Identify purchase validity based on whether purchase contains a valid eceipt?.source or eceipt?.receiptID or purchase.purchaseID. A purchase placeholder is invalid only if purchase.isLoaded is rue AND it neither has eceipt?.source / eceipt?.receiptID nor purchase.purchaseID. ` sx const hasValidReceipt = Boolean(purchase?.receipt?.source || purchase?.receipt?.receiptID); const isValidPurchase = Boolean(purchase?.purchaseID || hasValidReceipt);

    useEffect(() => { if (!purchase?.isLoaded || isValidPurchase) { return; }

    Navigation.dismissModal();
    

    }, [purchase?.isLoaded, isValidPurchase]);

    if (!isValidPurchase) { return null; } `

  2. In PaymentHistoryUtils.ts (getReceiptPurchase):

    • Check if purchase.receipt?.source exists directly on purchase before rejecting due to missing summary metadata (message or purchaseID): s if (purchase.receipt?.source) { return purchase; } if (!purchase?.purchaseID || !purchase.message) { return null; } This allows direct receipt lookups to resolve cleanly while keeping chained receipt traversal (e.g. cleared/failed bills requiring message.failedPurchaseID) protected against incomplete or cyclic chains.
  3. In isInvoiceBilling:

    • Ensure purchase?.message is safely accessed so missing summary metadata defaults gracefully to alse (receipt) rather than failing.

What alternative solutions did you explore? (Optional)

Populating purchaseID: numericPurchaseID in openPaymentDetailsPage's inallyData, but doing so unconditionally in inallyData would make genuinely invalid lookups (404s) appear valid. Validating whether purchase.receipt?.source exists directly in BillingReceiptModalContent and PaymentHistoryUtils accurately separates valid receipts from empty error placeholders.

jmquero92 avatar Nov 10 '26 11:11 jmquero92

:warning: Unable to store contributor details

Details
Auth SetContributorDetails returned an error
401 Contributor details already exist

melvin-bot[bot] avatar Nov 10 '26 11:11 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01ca8ad8ce36b9eceb

Proposal

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

When navigating directly to a valid purchase receipt deeplink (e.g. https://staging.new.expensify.com/settings/subscription/payment-history/:purchaseID/receipt), the payment receipt does not display and the modal dismisses immediately.

What is the root cause of that problem?

Regression introduced in PR #106315. When a user accesses a receipt directly via deeplink, purchases in Onyx does not contain the full purchase record loaded by OpenSubscriptionPage (which populates purchaseID, mount, currency, and message). Instead, BillingReceiptModalContent calls openPaymentDetailsPage(numericPurchaseID), which fetches and merges the purchase detail from the backend (specifically eceipt: { receiptID, source }, ctiveUsers, illedToAccountID) and marks [purchaseID]: { isLoaded: true } in inallyData.

PR #106315 added an effect and early return in BillingReceiptModalContent.tsx: ` sx useEffect(() => { if (!purchase?.isLoaded || purchase.purchaseID) { return; }

    Navigation.dismissModal();
}, [purchase?.isLoaded, purchase?.purchaseID]);

if (!purchase.purchaseID) {
    return null;
}

` Because OpenPaymentDetailsPage merges the receipt details under key purchases[purchaseID] without duplicating purchaseID inside the nested object, purchase.purchaseID is undefined on a direct deeplink even when eceipt.source is valid. As soon as isLoaded becomes rue, the useEffect triggers Navigation.dismissModal(), closing the modal immediately.

Additionally, in PaymentHistoryUtils.ts:344: s if (!purchase?.purchaseID || !purchase.message) { return null; } getReceiptPurchase rejects any purchase missing purchaseID or message before checking purchase.receipt?.source. Since a direct deeplink lookup only has detail data without message, getReceiptPurchase returns ull, and getReceiptSource resolves to ull.

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

  1. In BillingReceiptModalContent.tsx:

    • Identify purchase validity based on whether purchase contains a valid eceipt?.source or eceipt?.receiptID or purchase.purchaseID. A purchase placeholder is invalid only if purchase.isLoaded is rue AND it neither has eceipt?.source / eceipt?.receiptID nor purchase.purchaseID. ` sx const hasValidReceipt = Boolean(purchase?.receipt?.source || purchase?.receipt?.receiptID); const isValidPurchase = Boolean(purchase?.purchaseID || hasValidReceipt);

    useEffect(() => { if (!purchase?.isLoaded || isValidPurchase) { return; }

    Navigation.dismissModal();
    

    }, [purchase?.isLoaded, isValidPurchase]);

    if (!isValidPurchase) { return null; } `

  2. In PaymentHistoryUtils.ts (getReceiptPurchase):

    • Check if purchase.receipt?.source exists directly on purchase before rejecting due to missing summary metadata (message or purchaseID): s if (purchase.receipt?.source) { return purchase; } if (!purchase?.purchaseID || !purchase.message) { return null; } This allows direct receipt lookups to resolve cleanly while keeping chained receipt traversal (e.g. cleared/failed bills requiring message.failedPurchaseID) protected against incomplete or cyclic chains.
  3. In isInvoiceBilling:

    • Ensure purchase?.message is safely accessed so missing summary metadata defaults gracefully to alse (receipt) rather than failing.

What alternative solutions did you explore? (Optional)

Populating purchaseID: numericPurchaseID in openPaymentDetailsPage's inallyData, but doing so unconditionally in inallyData would make genuinely invalid lookups (404s) appear valid. Validating whether purchase.receipt?.source exists directly in BillingReceiptModalContent and PaymentHistoryUtils accurately separates valid receipts from empty error placeholders.

jmquero92 avatar Nov 10 '26 11:11 jmquero92

:warning: Unable to store contributor details

Details
Auth SetContributorDetails returned an error
401 Contributor details already exist

melvin-bot[bot] avatar Nov 10 '26 11:11 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01ca8ad8ce36b9eceb

Proposal

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

When navigating directly to a valid purchase receipt deeplink (e.g. https://staging.new.expensify.com/settings/subscription/payment-history/:purchaseID/receipt), the payment receipt does not display and the modal dismisses immediately.

What is the root cause of that problem?

Regression introduced in PR #106315. When a user accesses a receipt directly via deeplink, purchases in Onyx does not contain the full purchase record loaded by OpenSubscriptionPage (which populates purchaseID, mount, currency, and message). Instead, BillingReceiptModalContent calls openPaymentDetailsPage(numericPurchaseID), which fetches and merges the purchase detail from the backend (specifically eceipt: { receiptID, source }, ctiveUsers, illedToAccountID) and marks [purchaseID]: { isLoaded: true } in inallyData.

PR #106315 added an effect and early return in BillingReceiptModalContent.tsx: ` sx useEffect(() => { if (!purchase?.isLoaded || purchase.purchaseID) { return; }

    Navigation.dismissModal();
}, [purchase?.isLoaded, purchase?.purchaseID]);

if (!purchase.purchaseID) {
    return null;
}

` Because OpenPaymentDetailsPage merges the receipt details under key purchases[purchaseID] without duplicating purchaseID inside the nested object, purchase.purchaseID is undefined on a direct deeplink even when eceipt.source is valid. As soon as isLoaded becomes rue, the useEffect triggers Navigation.dismissModal(), closing the modal immediately.

Additionally, in PaymentHistoryUtils.ts:344: s if (!purchase?.purchaseID || !purchase.message) { return null; } getReceiptPurchase rejects any purchase missing purchaseID or message before checking purchase.receipt?.source. Since a direct deeplink lookup only has detail data without message, getReceiptPurchase returns ull, and getReceiptSource resolves to ull.

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

  1. In BillingReceiptModalContent.tsx:

    • Identify purchase validity based on whether purchase contains a valid eceipt?.source or eceipt?.receiptID or purchase.purchaseID. A purchase placeholder is invalid only if purchase.isLoaded is rue AND it neither has eceipt?.source / eceipt?.receiptID nor purchase.purchaseID. ` sx const hasValidReceipt = Boolean(purchase?.receipt?.source || purchase?.receipt?.receiptID); const isValidPurchase = Boolean(purchase?.purchaseID || hasValidReceipt);

    useEffect(() => { if (!purchase?.isLoaded || isValidPurchase) { return; }

    Navigation.dismissModal();
    

    }, [purchase?.isLoaded, isValidPurchase]);

    if (!isValidPurchase) { return null; } `

  2. In PaymentHistoryUtils.ts (getReceiptPurchase):

    • Check if purchase.receipt?.source exists directly on purchase before rejecting due to missing summary metadata (message or purchaseID): s if (purchase.receipt?.source) { return purchase; } if (!purchase?.purchaseID || !purchase.message) { return null; } This allows direct receipt lookups to resolve cleanly while keeping chained receipt traversal (e.g. cleared/failed bills requiring message.failedPurchaseID) protected against incomplete or cyclic chains.
  3. In isInvoiceBilling:

    • Ensure purchase?.message is safely accessed so missing summary metadata defaults gracefully to alse (receipt) rather than failing.

What alternative solutions did you explore? (Optional)

Populating purchaseID: numericPurchaseID in openPaymentDetailsPage's inallyData, but doing so unconditionally in inallyData would make genuinely invalid lookups (404s) appear valid. Validating whether purchase.receipt?.source exists directly in BillingReceiptModalContent and PaymentHistoryUtils accurately separates valid receipts from empty error placeholders.

jmquero92 avatar Nov 10 '26 11:11 jmquero92

:warning: Unable to store contributor details

Details
Auth SetContributorDetails returned an error
401 Contributor details already exist

melvin-bot[bot] avatar Nov 10 '26 11:11 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01ca8ad8ce36b9eceb

Proposal

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

When navigating directly to a valid purchase receipt deeplink (e.g. https://staging.new.expensify.com/settings/subscription/payment-history/:purchaseID/receipt), the payment receipt does not display and the modal dismisses immediately.

What is the root cause of that problem?

Regression introduced in PR #106315. When a user accesses a receipt directly via deeplink, purchases in Onyx does not contain the full purchase record loaded by OpenSubscriptionPage (which populates purchaseID, mount, currency, and message). Instead, BillingReceiptModalContent calls openPaymentDetailsPage(numericPurchaseID), which fetches and merges the purchase detail from the backend (specifically eceipt: { receiptID, source }, ctiveUsers, illedToAccountID) and marks [purchaseID]: { isLoaded: true } in inallyData.

PR #106315 added an effect and early return in BillingReceiptModalContent.tsx: ` sx useEffect(() => { if (!purchase?.isLoaded || purchase.purchaseID) { return; }

    Navigation.dismissModal();
}, [purchase?.isLoaded, purchase?.purchaseID]);

if (!purchase.purchaseID) {
    return null;
}

` Because OpenPaymentDetailsPage merges the receipt details under key purchases[purchaseID] without duplicating purchaseID inside the nested object, purchase.purchaseID is undefined on a direct deeplink even when eceipt.source is valid. As soon as isLoaded becomes rue, the useEffect triggers Navigation.dismissModal(), closing the modal immediately.

Additionally, in PaymentHistoryUtils.ts:344: s if (!purchase?.purchaseID || !purchase.message) { return null; } getReceiptPurchase rejects any purchase missing purchaseID or message before checking purchase.receipt?.source. Since a direct deeplink lookup only has detail data without message, getReceiptPurchase returns ull, and getReceiptSource resolves to ull.

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

  1. In BillingReceiptModalContent.tsx:

    • Identify purchase validity based on whether purchase contains a valid eceipt?.source or eceipt?.receiptID or purchase.purchaseID. A purchase placeholder is invalid only if purchase.isLoaded is rue AND it neither has eceipt?.source / eceipt?.receiptID nor purchase.purchaseID. ` sx const hasValidReceipt = Boolean(purchase?.receipt?.source || purchase?.receipt?.receiptID); const isValidPurchase = Boolean(purchase?.purchaseID || hasValidReceipt);

    useEffect(() => { if (!purchase?.isLoaded || isValidPurchase) { return; }

    Navigation.dismissModal();
    

    }, [purchase?.isLoaded, isValidPurchase]);

    if (!isValidPurchase) { return null; } `

  2. In PaymentHistoryUtils.ts (getReceiptPurchase):

    • Check if purchase.receipt?.source exists directly on purchase before rejecting due to missing summary metadata (message or purchaseID): s if (purchase.receipt?.source) { return purchase; } if (!purchase?.purchaseID || !purchase.message) { return null; } This allows direct receipt lookups to resolve cleanly while keeping chained receipt traversal (e.g. cleared/failed bills requiring message.failedPurchaseID) protected against incomplete or cyclic chains.
  3. In isInvoiceBilling:

    • Ensure purchase?.message is safely accessed so missing summary metadata defaults gracefully to alse (receipt) rather than failing.

What alternative solutions did you explore? (Optional)

Populating purchaseID: numericPurchaseID in openPaymentDetailsPage's inallyData, but doing so unconditionally in inallyData would make genuinely invalid lookups (404s) appear valid. Validating whether purchase.receipt?.source exists directly in BillingReceiptModalContent and PaymentHistoryUtils accurately separates valid receipts from empty error placeholders.

jmquero92 avatar Nov 10 '26 11:11 jmquero92

:warning: Unable to store contributor details

Details
Auth SetContributorDetails returned an error
401 Contributor details already exist

melvin-bot[bot] avatar Nov 10 '26 11:11 melvin-bot[bot]