Skip to content

Show a reconnect warning when the QBO refresh token is about to expire - #101273

Merged
francoisl merged 13 commits into
Expensify:mainfrom
KioCoan:showQboRefreshTokenExpiryWarning
Sep 29, 2026
Merged

francoisl merged 13 commits into
Expensify:mainfrom
KioCoan:showQboRefreshTokenExpiryWarning

Conversation

@KioCoan

@KioCoan KioCoan commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The QuickBooks Online connection credentials in Onyx carry refreshTokenExpiresAt (epoch seconds, written by the backend on connect and on every Intuit refresh), but the App never read it, so a workspace whose refresh token was days from dying looked healthy until an export failed. This PR derives a warning from that value at render time, with no new Onyx state, and shows it to workspace admins when the token expires within 7 days or has already expired without a sync failing yet:

  • the Accounting page shows a hint under the QuickBooks Online row, "Your QuickBooks Online connection expires on ." (or "expired on"), followed by an inline Reconnect link that starts the QBO reconnect flow;
  • the three-dot menu on that row gains the existing Reconnect entry;
  • the Accounting item in the workspace left menu and the workspace row in the Workspaces list show the green INFO indicator, the same treatment the incomplete Merge HR setup uses. Existing error indicators keep precedence.

The helpers live in AccountingUtils and are pure (now is a parameter) so they are easy to test. Connections whose last sync already reports an authentication error are excluded because they already show the red error state. Both reconnect entry points now pass isIntuitEnterpriseSuite, so an Intuit Enterprise Suite workspace reconnects with the right scopes. The backend half of this feature, a Concierge message in #admins, is in Warn admins in-app before a QBO refresh token expires; the two PRs are independent and can deploy in any order.

Fixed Issues

https://github.com/Expensify/Expensify/issues/679790

Tests

Requires a workspace connected to QuickBooks Online whose connections.quickbooksOnline.config.credentials.refreshTokenExpiresAt is within 7 days. On the dev VM, set it through PolicyAPI::setConnectionData or edit the policy NVP directly; the value is epoch seconds.

  1. Sign in as an admin of that workspace and open Workspaces.
  2. Verify the workspace row shows a green dot on the right.
  3. Open the workspace and verify the Accounting item in the left menu shows a green dot.
  4. Open Accounting and verify the QuickBooks Online row shows "Your QuickBooks Online connection expires on . Reconnect" under "Last synced".
  5. Click Reconnect and verify the QuickBooks Online authorization page opens.
  6. Open the three-dot menu on the QuickBooks Online row and verify it lists Reconnect, Sync now and Disconnect.
  7. Click Reconnect in that menu and verify the QuickBooks Online authorization page opens.
  8. Set the expiry to a past date and verify the hint reads "Your QuickBooks Online connection expired on . Reconnect" and both green dots remain.
  9. Set the expiry to 30 days out and verify the hint and both green dots disappear, and the three-dot menu lists Sync now and Disconnect only.
  10. Set lastSync.isAuthenticationError to true with an expiry within 7 days and verify only the existing red error state shows, with no hint and no green dot.
  11. Sign in as a non-admin member of the workspace and verify no green dot shows on the Workspaces list.
  12. Run npm run test -- tests/unit/AccountingUtilsTest.ts tests/unit/PolicyUtilsTest.ts tests/unit/getWorkspaceMenuItemsTest.ts and verify all suites pass.
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

The warning cannot be triggered on staging because Intuit issues a fresh 100-day refresh token on every sync. Please regression test the surrounding flows:

  1. Sign in to staging NewDot as the admin of a Collect workspace and open Workspaces.
  2. Verify the workspace row shows no green dot on the right.
  3. Open the workspace > Accounting and connect QuickBooks Online (Intuit sandbox company).
  4. After the first sync, verify the QuickBooks Online row shows "Last synced ..." with no hint below it.
  5. Verify the Accounting item in the workspace left menu and the workspace row in the Workspaces list show no green dot.
  6. Open the three-dot menu on the QuickBooks Online row and verify it lists Sync now and Disconnect only.
  7. Click Disconnect, confirm, then connect QuickBooks Online again and verify both flows still work.
  8. Sign in as a non-admin member of the same workspace and verify the Workspaces list shows no indicator on that workspace.
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Before:
03-before-accounting-page

After:
04-after-accounting-page-expiring
07-after-overflow-menu-expiring
05-after-workspace-lhn-expiring
06-after-workspaces-list-expiring
09-after-accounting-page-expired
10-after-accounting-page-healthy-30d

@melvin-bot

melvin-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx bun ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx bun ./scripts/generateTranslations.ts --compare-ref main

@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/CONST/index.ts 95.79% <ø> (+6.72%) ⬆️
...kspaceListTable/WorkspaceRowBrickRoadIndicator.tsx 83.33% <100.00%> (+0.72%) ⬆️
src/libs/AccountingUtils.ts 93.61% <100.00%> (+3.29%) ⬆️
src/libs/PolicyUtils.ts 83.96% <100.00%> (+2.18%) ⬆️
...ages/workspace/accounting/PolicyAccountingPage.tsx 72.72% <100.00%> (+15.53%) ⬆️
src/pages/workspace/getWorkspaceMenuItems.ts 100.00% <100.00%> (ø)
... and 2367 files with indirect coverage changes

@KioCoan
KioCoan requested a review from francoisl September 26, 2026 01:07
@KioCoan
KioCoan marked this pull request as ready for review September 26, 2026 01:07
@KioCoan
KioCoan requested review from a team as code owners September 26, 2026 01:07
@melvin-bot
melvin-bot Bot requested review from joekaufmanexpensify and rlinoz and removed request for a team September 26, 2026 01:07
@melvin-bot

melvin-bot Bot commented Sep 26, 2026

Copy link
Copy Markdown

@rlinoz Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

Comment thread src/components/Tables/WorkspaceListTable/WorkspaceRowBrickRoadIndicator.tsx Outdated
@rlinoz
rlinoz removed their request for review September 28, 2026 14:48
Comment thread Mobile-Expensify

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to commit that? Looks like it's causing a conflict

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. I reverted the reference. Thanks.

@joekaufmanexpensify joekaufmanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. This is a great product change.

}

let qboTokenExpiryHint;
if (qboTokenExpiryDate) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to check && canWriteAccounting here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's fair. Included it and a test to cover.

@francoisl

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@francoisl
francoisl merged commit 87c6f97 into Expensify:main Sep 29, 2026
35 of 39 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 francoisl has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@KioCoan
KioCoan deleted the showQboRefreshTokenExpiryWarning branch September 29, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants