Skip to content

[cp stag] Fix product marketing window flicker during account rehydration - #97861

Merged
JS00001 merged 10 commits into
Expensify:mainfrom
KJ21-ENG:KJ21-ENG/95791-product-window-rehydration-gate
Aug 5, 2026
Merged

JS00001 merged 10 commits into
Expensify:mainfrom
KJ21-ENG:KJ21-ENG/95791-product-window-rehydration-gate

Conversation

@KJ21-ENG

@KJ21-ENG KJ21-ENG commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

This is a follow-up to #96141 that fixes one account-rehydration race exposed through two paths: returning from copilot access and using Clear cache and restart.

Account-scoped resets temporarily remove the product-marketing dismissal NVP. During that interval, an absent dismissal could be interpreted as eligibility and briefly remount an already-dismissed window. This change introduces a persisted reset-generation handshake shared by every browser tab. The window stays hidden until a successful OpenApp or full ReconnectApp adds the current generation to a ready-generation map after applying the complete account data, including the dismissal NVP. Queued requests wait for the queue to drain, while full side-effect reconnects mark readiness through success data after their HTTPS payload is applied. Because each request can only add the generation it began under, a stale response cannot open a newer unfinished generation or close a newer finished one. An unfinished reset also remains hidden across a process restart. Imported state explicitly marks the current generation ready because it intentionally bypasses OpenApp.

Fixed Issues

$ #97834
$ #97846
PROPOSAL: #95791 (comment)

Tests

  1. Sign in with an eligible admin account, create a workspace, and dismiss the product marketing window.
  2. Connect as a copilot for another account, then return to the original account.
  3. Verify the dismissed product marketing window does not reappear or flash during the transition.
  4. Open Settings > Troubleshoot and select Clear cache and restart.
  5. Verify the dismissed product marketing window does not reappear or flash while the account reloads.
  6. Sign in with a different eligible account that has not dismissed the current announcement.
  7. Verify the product marketing window still appears normally and can be dismissed.
  • Verify that no errors appear in the JS console

Offline tests

Automated coverage verifies that a failed OpenApp, stale pre-reset response, and queued or side-effect partial ReconnectApp do not mark the current generation ready, while current-generation queued and side-effect full ReconnectApp do.

  1. Start with the product marketing window dismissed, then force the app offline.
  2. Clear cache and restart.
  3. Verify the product marketing window does not flash while OpenApp cannot complete.
  4. Reconnect, allow OpenApp to finish, and verify the dismissed window remains hidden.

QA Steps

Same as Tests.

  • 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
Screen.Recording.2026-08-05.at.12.48.22.PM.compressed.mp4

@codecov

codecov Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/libs/actions/App.ts 58.18% <ø> (ø)
src/libs/actions/Delegate.ts 30.81% <ø> (ø)
... and 8 files with indirect coverage changes

@KJ21-ENG
KJ21-ENG marked this pull request as ready for review August 5, 2026 09:53
@KJ21-ENG
KJ21-ENG requested review from a team as code owners August 5, 2026 09:53
@melvin-bot
melvin-bot Bot requested review from flaviadefaria and huult and removed request for a team August 5, 2026 09:53
@melvin-bot

melvin-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

@huult 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team August 5, 2026 09:53
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

Comment thread src/libs/actions/App.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0984cb4040

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/libs/actions/App.ts Resolved
@huult

huult commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

I’ll review this PR within the next 4 hours

Comment thread src/libs/actions/App.ts Outdated
// Full account requests capture this generation when they are created. Their success handoff only
// marks that captured generation ready, so a response that finishes after another reset stays stale.
let productMarketingWindowDataResetID: string | undefined;
Onyx.connectWithoutView({

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.

we shouldnt be using connectWithoutView

Comment thread src/setup/index.ts Outdated
willAlertModalBecomeVisible: false,
},
[ONYXKEYS.RAM_ONLY_IS_PRODUCT_MARKETING_WINDOW_COVERED]: false,
// PRODUCT_MARKETING_WINDOW_DATA_STATE intentionally has no default. Onyx initial defaults

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.

we dont need this comment

@huult

huult commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@KJ21-ENG Could you please check @JS00001's comment?

@huult

huult commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

@KJ21-ENG

#97846

I don't think that's the right solution. We can fix this by simply adding NVP_LAST_DISMISSED_MARKETING_WINDOW to KEYS_TO_PRESERVE.

add:

ONYXKEYS.NVP_LAST_DISMISSED_MARKETING_WINDOW,

#97834

Could you share the RCA for this issue?

I think we can simply add NVP_LAST_DISMISSED_MARKETING_WINDOW to KEYS_TO_PRESERVE_DELEGATE_ACCESS.

https://github.com/huult/App/blob/23c1add9bbfac89ff26f23afcb38da0cd67396b5/src/libs/actions/Delegate.ts#L43

    // Otherwise it's wiped and refetched by OpenApp, letting the product-marketing window flash back in
    // before the dismissal value round-trips back from the server.
    ONYXKEYS.NVP_LAST_DISMISSED_MARKETING_WINDOW,

@KJ21-ENG

KJ21-ENG commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@huult The current implementation uses a persisted reset generation because both issues happen while account-scoped Onyx data is being cleared and rehydrated.

Each full OpenApp/ReconnectApp captures the generation it starts under and only marks that same generation ready after its complete response data has been applied. Until then, the product marketing window stays hidden. This prevents an older in-flight request from unblocking a newer reset, and lets a later full reconnect complete a pending reset after a failed request or app restart.

That is the reason I used the shared rehydration gate instead of relying only on IS_LOADING_APP, which can settle before all of the destination account data has been applied.

@huult

huult commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

https://github.com/huult/App/pull/new/97846-test-branch

Screen.Recording.2026-08-05.at.22.38.13.mov

@KJ21-ENG I opened a draft solution. Could you take a look?

@huult

huult commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@KJ21-ENG Are you still working on the update?

@KJ21-ENG

KJ21-ENG commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@huu1t Yes, I found an additional case during testing. If we preserves the existing dismissal value across both clears without checking which account it belongs to. I have doubt that this could carry an agent’s dismissal state over to an owner who never dismissed the window, So checking that

@huult

huult commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@KJ21-ENG We should fix the deploy blocker first. We can investigate and fix the other issues later.

@JS00001

JS00001 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@KJ21-ENG any updates here? These are the last 2 blockers

@KJ21-ENG

KJ21-ENG commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Apologies guys, I had to go AFK for some unforeseen reasons. I think we are good to go with this. 7f7409f . Thanks @huult for help

cc: @huult @JS00001

Screen.Recording.2026-08-05.at.9.44.31.PM.compressed.mp4

@JS00001

JS00001 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@KJ21-ENG so this is ready for review?

@KJ21-ENG

KJ21-ENG commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@JS00001 Yes

@JS00001
JS00001 requested a review from marufsharifi August 5, 2026 20:08

@JS00001 JS00001 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.

lgtm

@JS00001

JS00001 commented Aug 5, 2026

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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

@JS00001

JS00001 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This is fixed, tested locally

Screen.Recording.2026-08-05.at.5.33.24.PM.mov

@JS00001 JS00001 changed the title Fix product marketing window flicker during account rehydration [cp stag] Fix product marketing window flicker during account rehydration Aug 5, 2026
@JS00001
JS00001 merged commit f86bc34 into Expensify:main Aug 5, 2026
36 of 38 checks passed
OSBotify pushed a commit that referenced this pull request Aug 5, 2026
…-rehydration-gate

[cp stag] Fix product marketing window flicker during account rehydration

(cherry picked from commit f86bc34)

(cherry-picked to staging by arosiclair)
@OSBotify OSBotify added the CP Staging marks PRs that have been CP'd to staging label Aug 5, 2026
@OSBotify

OSBotify commented Aug 5, 2026

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.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify OSBotify mentioned this pull request Aug 5, 2026
52 tasks done
@OSBotify

OSBotify commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/arosiclair in version: 9.4.50-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required.

I reviewed the changes in this PR against the help site articles under docs/articles. This PR is a purely internal fix — it adds NVP_LAST_DISMISSED_MARKETING_WINDOW to the lists of Onyx keys preserved during account-scoped resets (src/libs/actions/App.ts and src/libs/actions/Delegate.ts) so a dismissed product marketing window doesn't briefly flash back in while account data rehydrates after returning from Copilot access or a Clear cache and restart.

There's no user-facing feature, UI, tab, setting, or button change here — it fixes a transient flicker so the existing (correct) behavior stays correct. Nothing in the public help articles documents the product marketing window's rehydration timing, so no article needs updating.

No draft PR was created.

@KJ21-ENG, please confirm you agree no help site update is needed here. If you believe this behavior should be documented, let me know and I'll open a draft help site PR.

@OSBotify

OSBotify commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.4.50-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@OSBotify

OSBotify commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/arosiclair in version: 9.4.51-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required (reconfirmed).

As I noted in my earlier review, this PR is a purely internal fix — it adds NVP_LAST_DISMISSED_MARKETING_WINDOW to the Onyx keys preserved during account-scoped resets (src/libs/actions/App.ts and src/libs/actions/Delegate.ts) so a dismissed product marketing window doesn't briefly flash back during rehydration after returning from Copilot access or a Clear cache and restart.

There's no user-facing feature, UI, tab, setting, or button change — the existing behavior is unchanged; the fix just removes a transient flicker. No public help article documents the marketing window's rehydration timing, so nothing under docs/articles needs updating and no draft PR was created.

@KJ21-ENG, please confirm you agree no help site update is needed here. If you believe this behavior should be documented, let me know and I'll open a draft help site PR.

@huult

huult commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

i am back

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.51-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

CP Staging marks PRs that have been CP'd to staging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants