Skip to content

Reset stale tab title to "New Expensify" on logout#96916

Open
MelvinBot wants to merge 3 commits into
mainfrom
claude-resetTabTitleOnLogout
Open

Reset stale tab title to "New Expensify" on logout#96916
MelvinBot wants to merge 3 commits into
mainfrom
claude-resetTabTitleOnLogout

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

On web, after logging out the browser tab title stayed stuck on the last visited authenticated page (e.g. "Profile") instead of resetting to "New Expensify".

The tab title is driven by a module-level currentPageTitle in updateUnread/index.ts, which is only ever written (via setPageTitle) by the useDocumentTitle hook on screen focus. updateDocumentTitle() only falls back to CONFIG.SITE_TITLE ("New Expensify") when currentPageTitle is empty. The design deliberately relies on the next focused page overwriting the title — a blur/unmount cleanup used to exist but was removed in #85473 because it raced the async title pipeline and flashed the default title mid-navigation. That assumption holds while navigating between authenticated pages, but breaks on logout: the destination is a public screen (Sign-In), which never calls useDocumentTitle, so nothing overwrites the stale title.

This implements the signed-out-root-screen approach: add useDocumentTitle('') to SignInPage (the public/signed-out root screen). On logout the app lands on SignInPage, whose focus effect now sets an empty page title, so updateDocumentTitle() falls back to CONFIG.SITE_TITLE ("New Expensify").

This follows the natural operation of the hook — every screen owns its own title on focus, and the Sign-In screen simply declares its (empty) title like any other screen — rather than adding an out-of-band cleanup or Onyx subscription. It fires only on focus of the signed-out screen, so it does not reintroduce the #85473 mid-navigation flicker, and setPageTitle is a no-op on native, so the change is web-safe with no platform guard.

Fixed Issues

$ #95208
PROPOSAL: #95208 (comment)

Tests

  1. On web, log in and navigate to a titled page (e.g. Settings > Profile). Confirm the browser tab title shows the page title (e.g. "Profile").
  2. Log out.
  3. Verify the browser tab title resets to "New Expensify".
  4. Log back in and navigate between several titled pages (e.g. Profile → Preferences → a chat report). Verify each page's title shows correctly and there is no flash to "New Expensify" mid-navigation.
  • Verify that no errors appear in the JS console

Offline tests

  1. On web, log in and open a titled page (e.g. Settings > Profile) and confirm the tab title shows the page name.
  2. Log out and verify the tab title resets to "New Expensify".
  3. Navigate between titled pages and verify titles update correctly with no flicker to "New Expensify".
  • 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

Co-authored-by: Tyler Karaszewski <tylerkaraszewski@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

The only failing check is PR Author Checklist / checklist — every other check is passing or still running (the test, typecheck, spellcheck, and perf jobs were pending at the time I looked).

There's no code defect to push a fix for here. That check fails for two reasons, both of which need a human on the PR rather than a code change:

  1. The PR Author Checklist boxes aren't ticked. These are human-verification boxes ("I verified…", "Verify that no errors appear in the JS console", etc.), so I won't check them on the author's behalf — they're meant to attest that a person thought through each item. The assignee should tick them in the PR body.
  2. The check also logged Could not verify engineering membership for MelvinBot. Assuming they are not a member — since this PR was opened by MelvinBot, the author-checklist automation can't attribute it to an engineer.

To get this green: open the checklist section in the PR description and check each box you've verified. Once the boxes are filled in, re-running the checklist job should pass. The pending test/typecheck/perf jobs should be left to finish on their own.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/pages/signin/SignInPage.tsx 85.93% <100.00%> (+0.33%) ⬆️
src/pages/signin/SignInModal.tsx 0.00% <0.00%> (ø)
... and 87 files with indirect coverage changes

…umentTitle('') on SignInPage

Co-authored-by: Sahil <thesahindia@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Switched this PR to the signed-out-root-screen approach per thesahindia's direction on the linked issue.

  • Reverted the useDocumentTitle blur-cleanup change.
  • Added useDocumentTitle('') to SignInPage, so on logout the signed-out root screen sets an empty page title and updateDocumentTitle() falls back to CONFIG.SITE_TITLE ("New Expensify").

Net diff is now 2 files (+7 / −24). The PR description has been updated to match. Local oxfmt, ESLint (0 errors), tsgo typecheck, React Compiler compliance, and tests/navigation/PublicSignInPageRootUrlTest.tsx all pass.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I looked into the failing checks — there's nothing to fix with a code push.

The only failing check is PR Author Checklist / checklist, and it's failing for a non-code reason. Its log says:

You completed 0 out of 38 checklist items with 38 unfinished items
##[error]PR Author Checklist is not completely filled out. Please check every box to verify you've thought about the item.

This check only passes once the author ticks the checklist boxes in the PR description — it's not something I can resolve by changing code.

Every actual CI check is green: all 8 Jest test jobs, typecheck, ESLint, Oxfmt, Bun tests, Storybook tests, spellcheck, knip, unused-styles, React Compiler, and all Android/iOS build jobs pass. The only checks still pending are the two Reassure perf tests (baseline-perf-tests / branch-perf-tests), which are still running and aren't failing.

To get everything green: complete the PR Author Checklist in the description (check every box). No code change is needed.

@thesahindia

Copy link
Copy Markdown
Member

@MelvinBot mark off all the items in the checklist

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Done — checked off all 40 items in the PR description (both the Tests/Offline tests console-error boxes and every box in the PR Author Checklist). Re-running the PR Author Checklist / checklist job should now pass.

One heads-up: the checklist automation also logged Could not verify engineering membership for MelvinBot. Assuming they are not a member. If that keeps the check red even with the boxes ticked, it'll need a human author/assignee on the PR rather than a description edit.

@thesahindia

Copy link
Copy Markdown
Member

@MelvinBot mark the PR as ready for review

@MelvinBot
MelvinBot marked this pull request as ready for review July 24, 2026 11:05
@MelvinBot
MelvinBot requested a review from a team as a code owner July 24, 2026 11:05
@melvin-bot
melvin-bot Bot requested a review from thesahindia July 24, 2026 11:05
@melvin-bot

melvin-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

@thesahindia 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 requested review from heyjennahay and removed request for a team July 24, 2026 11:05
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Done — marked this PR as ready for review. It's now out of draft state.

@melvin-bot
melvin-bot Bot removed the request for review from a team July 24, 2026 11:05
@thesahindia

Copy link
Copy Markdown
Member

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
Screen.Recording.2026-07-24.at.4.21.28.PM.mov

@melvin-bot
melvin-bot Bot requested a review from tylerkaraszewski July 24, 2026 11:10

@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: 1eb900109b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// Reset the browser tab title on the signed-out root screen so it falls back to the site title ("New Expensify").
// Authenticated pages set a page-specific title via useDocumentTitle, but nothing clears it on logout, so the tab
// would otherwise stay stuck on the last visited page's title. This is a no-op on native.
useDocumentTitle('');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope the title reset to the root sign-in screen

When an anonymous user is viewing an anonymous-accessible report and clicks Sign in, signOutAndRedirectToSignIn() opens ROUTES.SIGN_IN_MODAL, and SignInModal renders this same SignInPage component. Since useDocumentTitle('') runs from the focused modal too, it clears the report’s document title back to CONFIG.SITE_TITLE even though the user has not landed on the signed-out root screen. Please gate this reset to the public root sign-in route or keep it out of the reusable modal instance.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure if it's an issue but @MelvinBot let’s implement it

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.

Good catch — implemented in f63d144. This is a real issue: SignInModal renders this same SignInPage component, so useDocumentTitle('') fired from the modal too and would clear the underlying anonymous-accessible report's tab title.

Rather than reintroduce route-name coupling, I gated the reset behind an explicit prop:

  • Added a shouldResetTabTitle prop to SignInPage (defaults to true), and moved the useDocumentTitle('') call into a tiny ResetTabTitleOnFocus child that only mounts when the prop is true. Threaded the prop through SignInPageWrapper and the WithTheme HOC.
  • SignInModal now passes shouldResetTabTitle={false}, so the reusable modal instance never touches the title.
  • The public root sign-in screen (registered in PublicScreens) renders the default export with no prop, so it keeps resetting to "New Expensify" on logout as intended.

Local checks: oxfmt, ESLint (0 errors), tsc typecheck (clean; the one BaseGenericTooltip TS2590 error is pre-existing and unrelated), React Compiler compliance, and the PublicSignInPageRootUrlTest + SessionTest suites all pass.

Gate useDocumentTitle('') behind a shouldResetTabTitle prop (default true) and
pass false from SignInModal so opening the sign-in modal over an
anonymous-accessible report no longer clears that report's tab title.

Co-authored-by: thesahindia <sahhtml@gmail.com>
Co-authored-by: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"} <{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"}@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team as a code owner July 24, 2026 11:47
@melvin-bot
melvin-bot Bot requested review from thesahindia and removed request for a team July 24, 2026 11:47
@melvin-bot

melvin-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

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

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.

3 participants