App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Connections - Error is being displayed when trying to Export a Report to Rillet

Open applause-bot[bot] opened this issue 4 weeks ago • 33 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.31-0 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/104889 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: MacOs Tahoe / Safari 26.2 App Component: Other

Action Performed:

  1. Open https://staging.new.expensify.com/
  2. Navigate to Workspaces and select 'Connections'
  3. Locate Rillet and sign in using API key
  4. Click on 'Export' and select 'Export reimbursable expenses as Reimbursable'
  5. Now Create a new Report and fill it with an Expense
  6. Submit and Approve the Expense
  7. Click on 'More', select 'Export' and select 'Export to Rillet'

Expected Result:

No error should be displayed when exporting a Report to RIllet

Actual Result:

An error is displayed in Report Thread when trying to export to Rillet

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/f4cb474d-8f07-45a9-9f2f-051ba606766a

View all open jobs on GitHub

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

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Nov 04 '26 11: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/789f9749f624734d37f9c4cc6a815bff6db5ec5baad845f84ca7e23361876b51

applause-bot[bot] avatar Nov 04 '26 11:11 applause-bot[bot]

🤖 Web test steps verification results: ⚠️ partial

Verified on dev NewDot web. Rillet was located, but a paid Control-plan upgrade gate blocked connection; issue 105899 could not be reproduced.

Rillet requires a paid Control-plan upgrade
Step Status
Open AppAuthenticated Home screen rendered after onboarding.
✅
Navigate Workspaces > ConnectionsConnections heading and integration list appeared.
✅
Locate Rillet and connectRillet was listed, but selecting it displayed a Control-plan upgrade requirement. No API key was supplied.
Rillet requires a paid Control-plan upgrade
⚠️
Configure Reimbursements export and inspect reimbursement accountBlocked by unavailable Rillet connection.
⚠️
Create report with expenseNot attempted after the required integration fixture was blocked.
⚠️
Submit and approveBlocked downstream.
⚠️
Export to Rillet and inspect report-thread errorNo export or report-thread error verified.
⚠️

view run

MelvinBot avatar Nov 04 '26 12:11 MelvinBot

⚠️ Preliminary analysis (low confidence) — treat as a starting point, not a conclusion.

A missing reimbursement account could explain the export failure, but the root cause is unconfirmed. Your reported steps omit account selection; the feature PR’s test steps require it.

Evidence and alternative explanation

Selecting Reimbursements saves the export mode without requiring an account (RilletReimbursablePage.tsx:48–53). A missing account triggers an admin warning, but does not block manual export (errors.ts:82–100, ReportSecondaryActionUtils.ts:555–592).

An unrelated export rejection could produce the same thread error (Report/index.ts:7158–7174). Omitted instructions do not prove the account was unset.

Web verification stopped at the Control-plan gate; no Rillet API key was available. Production logs were unavailable.

To confirm: Select an eligible reimbursement account, verify it persists after reloading, then retry export. Capture the exact thread error if it still fails. Compare against the missing-account case before choosing a fix.


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


view run · view recording

MelvinBot avatar Nov 04 '26 12:11 MelvinBot

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

melvin-bot[bot] avatar Nov 04 '26 12:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 04 '26 12:11 melvin-bot[bot]

📣 @aion-citadel-forge! 📣 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>

melvin-bot[bot] avatar Nov 04 '26 17:11 melvin-bot[bot]

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

aion-citadel-forge avatar Nov 04 '26 18:11 aion-citadel-forge

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

melvin-bot[bot] avatar Nov 04 '26 18:11 melvin-bot[bot]

Reviewing ASAP.

brunovjk avatar Nov 05 '26 18:11 brunovjk

Proposal

What is the root cause of that problem?

In PR #104889 (Add Rillet reimbursements as an out-of-pocket export option), the ability to export reimbursable expenses as Reimbursements was introduced. However, two gaps in validation permit an invalid export state:

  1. Premature Navigation without Account Selection in RilletReimbursablePage.tsx: In src/pages/workspace/accounting/rillet/export/RilletReimbursablePage.tsx:

    const selectReimbursableExpensesExportDestination = (item: ReimbursableExpensesExportDestinationListItem) => {
        if (item.value !== exportReimbursable && policyID) {
            updateRilletReimbursableExpensesExportDestination(policyID, item.value, exportReimbursable);
        }
        Navigation.goBack(backPath);
    };
    

    When the user selects CONST.RILLET_EXPORT_REIMBURSABLE.REIMBURSEMENT, the selection is saved and the screen immediately pops back to RilletExportPage. If the workspace has never selected a reimbursement account (rilletConfig?.export?.reimbursementAccountCode is undefined), the configuration is left incomplete without forcing the user to pick an account.

  2. Unvalidated Export Invocation in useExportActions.ts: In src/hooks/useExportActions.ts:202-211:

    onSelected: () => {
        if (!connectedIntegration || !moneyRequestReport) {
            return;
        }
        if (isExported) {
            triggerExportOrConfirm(CONST.REPORT.EXPORT_OPTIONS.EXPORT_TO_INTEGRATION);
            return;
        }
        exportToIntegration(moneyRequestReport.reportID, connectedIntegration, policy);
    },
    

    The hook only checks !connectedIntegration (which returns 'rillet' from getValidConnectedIntegration). It does not verify whether the connection has a missing destination account (shouldShowReimbursableExportDestinationAccountError(policy, [connectedIntegration])). When exportToIntegration fires API.write(WRITE_COMMANDS.REPORT_EXPORT, ...), the backend rejects the export because reimbursementAccountCode is missing, triggering failureData in src/libs/actions/Report/index.ts:7084-7101 and rendering common.genericErrorMessage in the report thread.

  3. Missing Subscribed Setting in src/pages/workspace/accounting/utils.tsx: In src/pages/workspace/accounting/utils.tsx:524-533, exportSubscribedSettings for CONST.POLICY.CONNECTIONS.NAME.RILLET includes REIMBURSABLE but is missing CONST.RILLET_CONFIG.REIMBURSEMENT_ACCOUNT_CODE.

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

  1. In src/pages/workspace/accounting/rillet/export/RilletReimbursablePage.tsx: When the user selects CONST.RILLET_EXPORT_REIMBURSABLE.REIMBURSEMENT:

    • If !rilletConfig?.export?.reimbursementAccountCode, navigate directly to ROUTES.POLICY_ACCOUNTING_RILLET_REIMBURSEMENT_ACCOUNT.getRoute(policyID) instead of Navigation.goBack(backPath), ensuring the user selects a valid reimbursement account immediately.
    • If an account is already selected, return via Navigation.goBack(backPath).
  2. In src/hooks/useExportActions.ts: Before executing exportToIntegration, check shouldShowReimbursableExportDestinationAccountError(policy, [connectedIntegration]):

    • If true, block the failing API write and navigate the user (or prompt via modal) to ROUTES.POLICY_ACCOUNTING_RILLET_EXPORT.getRoute(policy.id) to configure the missing account, preventing an unhandled backend rejection.
  3. In src/pages/workspace/accounting/utils.tsx: Add CONST.RILLET_CONFIG.REIMBURSEMENT_ACCOUNT_CODE to exportSubscribedSettings under CONST.POLICY.CONNECTIONS.NAME.RILLET so that the Connections list displays the error brick road indicator when the required account is missing.

What alternative solutions did you explore? (Optional)

Only adding the check in useExportActions.ts: while this blocks the report action error, it still allows the user to leave the Rillet setup page in an invalid state. Guiding the user directly to RilletReimbursementAccountPage upon selecting Reimbursements fixes the issue at both the configuration layer and the export execution layer.

What automated tests can you add to prevent this from re-occurring?

  1. In tests/unit/pages/workspace/accounting/rillet/RilletReimbursablePageTest.tsx:
    • Test that selecting REIMBURSEMENT when reimbursementAccountCode is unset navigates to ROUTES.POLICY_ACCOUNTING_RILLET_REIMBURSEMENT_ACCOUNT.
    • Test that selecting VENDOR_BILL or selecting REIMBURSEMENT when an account is already configured calls Navigation.goBack().
  2. In tests/unit/useExportActionsTest.ts:
    • Test that exportToIntegration is not triggered and an error/navigation prompt is shown when shouldShowReimbursableExportDestinationAccountError is true.

Contributor details

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

kevinjosh10 avatar Nov 06 '26 06:11 kevinjosh10

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

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

@brunovjk the steps here never pick a Reimbursement account, and the export fails without one. Can you check if that's the error here, or if it still fails with an account selected?

lakchote avatar Nov 06 '26 12:11 lakchote

Proposal

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

When a workspace is connected to Rillet and the admin sets Export out-of-pocket expenses as to Reimbursements under Workspace > Accounting > Export without explicitly selecting a reimbursement liability account, attempting to export an approved report via More > Export > Export to Rillet fails and posts an export error message in the report thread.

What is the root cause of that problem?

In PR #104889 (src/pages/workspace/accounting/rillet/export/RilletReimbursablePage.tsx, lines 48–53), when the user selects Reimbursements (CONST.RILLET_CONFIG.REIMBURSABLE_EXPENSES_EXPORT_DESTINATION.REIMBURSEMENTS), selectExportType calls updateRilletReimbursableExpensesExportDestination and immediately closes or updates the setting even when rilletConfig?.export?.reimbursableAccount is empty/unset!

When reimbursableAccount is unset, RilletReimbursablePage.tsx neither auto-selects the first available liability/payable account from rilletConfig as a default when switching to Reimbursements nor enforces selecting an account before leaving/exporting, so the backend receives an export request with reimbursableExpensesExportDestination = 'reimbursements' and an empty reimbursableAccount, which Rillet rejects.

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

  1. In src/pages/workspace/accounting/rillet/export/RilletReimbursablePage.tsx (and src/libs/actions/connections/Rillet.ts):
    • When the user switches reimbursableExpensesExportDestination to CONST.RILLET_CONFIG.REIMBURSABLE_EXPENSES_EXPORT_DESTINATION.REIMBURSEMENTS and reimbursableAccount is currently empty, automatically default reimbursableAccount to the first valid account in the Rillet reimbursable accounts list (matching how Xero/NetSuite/QuickBooks Online export pages default their account selector when switching export modes), or keep the user on RilletReimbursablePage with the account selector visible rather than calling Navigation.goBack().
  2. In src/pages/workspace/accounting/rillet/export/RilletExportPage.tsx and RilletReimbursablePage.tsx, display a Red Brick Road (RBR) indicator / error message if reimbursableExpensesExportDestination === CONST.RILLET_CONFIG.REIMBURSABLE_EXPENSES_EXPORT_DESTINATION.REIMBURSEMENTS and no reimbursableAccount is selected.

What alternative solutions did you explore? (Optional)

We considered blocking the Export to Rillet button in the report header when reimbursableAccount is empty, but auto-defaulting reimbursableAccount to the first available account when selecting Reimbursements in RilletReimbursablePage.tsx (and not auto-closing the page before the user can see/confirm the account row) prevents the misconfiguration from happening in the first place.

jeffrey-graham avatar Nov 07 '26 02:11 jeffrey-graham

📣 @jeffrey-graham! 📣 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>

melvin-bot[bot] avatar Nov 07 '26 02:11 melvin-bot[bot]

Proposal

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

After connecting a workspace to Rillet and setting Export reimbursable expenses as to Reimbursement (CONST.RILLET_EXPORT_REIMBURSABLE.REIMBURSEMENT), exporting an approved expense report via More > Export > Export to Rillet fails and posts an export error in the report thread.

What is the root cause of that problem?

In PR #104889 (src/pages/workspace/accounting/rillet/export/RilletReimbursablePage.tsx:48-53 and src/libs/actions/connections/Rillet.ts:649-656), when the admin switches rilletConfig.export.reimbursable from vendor_bill to reimbursement, updateRilletReimbursableExpensesExportDestination only updates config.export.reimbursable without initializing config.export.reimbursementAccountCode (which remains undefined), and RilletReimbursablePage.tsx immediately calls Navigation.goBack(backPath).

Let's compare this with how RilletReimbursementAccountPage.tsx:44-59 filters valid reimbursement accounts from rilletData?.accounts:

accountItem.type === CONST.RILLET_ACCOUNT_TYPE.LIABILITY &&
accountItem.subtype !== CONST.RILLET_ACCOUNT_SUBTYPE.CREDIT_CARD &&
accountItem.subtype !== CONST.RILLET_ACCOUNT_SUBTYPE.ACCOUNTS_PAYABLE &&
accountItem.subtype !== CONST.RILLET_ACCOUNT_SUBTYPE.OTHER_LONG_TERM_LIABILITY &&
accountItem.status === CONST.RILLET_ACCOUNT_STATUS.ACTIVE

Because RilletReimbursablePage.tsx pops straight back to RilletExportPage without either auto-selecting a default valid reimbursement liability account or navigating to ROUTES.POLICY_ACCOUNTING_RILLET_REIMBURSEMENT_ACCOUNT.getRoute(policyID) when reimbursementAccountCode is missing, and because useExportActions.ts:203-212 triggers exportToIntegration(moneyRequestReport.reportID, connectedIntegration, policy) without checking shouldShowReimbursableExportDestinationAccountError(policy, [connectedIntegration]), the export API request is sent to the backend with no reimbursementAccountCode configured and fails in the report thread.

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

  1. Auto-default or route to account selection in src/pages/workspace/accounting/rillet/export/RilletReimbursablePage.tsx:48-53:
    • Extract the eligible reimbursement accounts filter (getRilletReimbursementAccounts(rilletData?.accounts)) shared with RilletReimbursementAccountPage.tsx.
    • When the user selects CONST.RILLET_EXPORT_REIMBURSABLE.REIMBURSEMENT and !rilletConfig?.export?.reimbursementAccountCode:
      • If eligible reimbursement accounts exist in rilletData?.accounts, either default reimbursementAccountCode to the first eligible account (updateRilletReimbursementAccount(policyID, defaultAccount.code, undefined)) or navigate directly to ROUTES.POLICY_ACCOUNTING_RILLET_REIMBURSEMENT_ACCOUNT.getRoute(policyID) so reimbursementAccountCode is never left unset.
// src/pages/workspace/accounting/rillet/export/RilletReimbursablePage.tsx
const selectReimbursableExpensesExportDestination = (item: ReimbursableExpensesExportDestinationListItem) => {
    if (item.value !== exportReimbursable && policyID) {
        updateRilletReimbursableExpensesExportDestination(policyID, item.value, exportReimbursable);
        if (item.value === CONST.RILLET_EXPORT_REIMBURSABLE.REIMBURSEMENT && !rilletConfig?.export?.reimbursementAccountCode) {
            Navigation.navigate(ROUTES.POLICY_ACCOUNTING_RILLET_REIMBURSEMENT_ACCOUNT.getRoute(policyID));
            return;
        }
    }
    Navigation.goBack(backPath);
};
  1. Also auto-populate a default reimbursementAccountCode in updateRilletReimbursableExpensesExportDestination (src/libs/actions/connections/Rillet.ts:649-656) when available:
    • When switching to CONST.RILLET_EXPORT_REIMBURSABLE.REIMBURSEMENT and reimbursementAccountCode is unset while an active short-term liability account exists in policy.connections.rillet.data.accounts, set the default reimbursementAccountCode so QA/users who select Reimbursement and immediately export have a valid account code configured.

What alternative solutions did you explore? (Optional)

We considered only showing a Red Brick Road indicator on RilletExportPage.tsx (which already checks shouldShowReimbursableExportDestinationAccountError at line 103), but in the reported QA flow the user selects Export reimbursable expenses as Reimbursable and goes straight to creating and exporting a report without selecting Reimbursement account. Defaulting reimbursementAccountCode when available (and routing to RilletReimbursementAccountPage when manual selection is needed) prevents the unconfigured export error.

tungnguyen84 avatar Nov 07 '26 06:11 tungnguyen84

📣 @ronanchnlps-bit! 📣 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>

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

⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.

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

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

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

⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.

melvin-bot[bot] avatar Nov 07 '26 12:11 melvin-bot[bot]

:warning: Unable to store contributor details

Details
Auth SetContributorDetails returned an error
401 Contributor details already exist

melvin-bot[bot] avatar Nov 07 '26 12:11 melvin-bot[bot]