Skip to content

[CP staging] Revert "Remove useDocumentTitle cleanup to fix tab title race condition"#86112

Closed
grgia wants to merge 1 commit intomainfrom
revert-85473-claude-removeDocumentTitleCleanup
Closed

[CP staging] Revert "Remove useDocumentTitle cleanup to fix tab title race condition"#86112
grgia wants to merge 1 commit intomainfrom
revert-85473-claude-removeDocumentTitleCleanup

Conversation

@grgia
Copy link
Contributor

@grgia grgia commented Mar 23, 2026

Reverts #85473

$ #86087

@grgia grgia requested a review from yuwenmemon March 23, 2026 15:57
@grgia grgia self-assigned this Mar 23, 2026
@grgia grgia requested review from a team as code owners March 23, 2026 15:57
@melvin-bot melvin-bot bot requested review from JmillsExpensify and removed request for a team March 23, 2026 15:57
@grgia grgia changed the title Revert "Remove useDocumentTitle cleanup to fix tab title race condition" [CP staging] Revert "Remove useDocumentTitle cleanup to fix tab title race condition" Mar 23, 2026
@grgia grgia requested a review from mananjadhav March 23, 2026 15:57
@melvin-bot melvin-bot bot requested a review from MarioExpensify March 23, 2026 15:57
@melvin-bot
Copy link

melvin-bot bot commented Mar 23, 2026

@MarioExpensify 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 March 23, 2026 15:57
@grgia grgia requested review from NikkiWines and removed request for JmillsExpensify and MarioExpensify March 23, 2026 15:58
Copy link

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

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: 68737dca1b

ℹ️ 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".

useFocusEffect(
useCallback(() => {
setPageTitle(title);
return () => setPageTitle('');

Choose a reason for hiding this comment

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

P1 Badge Don't reset the global tab title in the focus cleanup

In our React Navigation 7 setup, the function returned from useFocusEffect is an effect cleanup, not a blur-only handler. Calling setPageTitle('') here mutates the shared currentPageTitle in src/libs/UnreadIndicatorUpdater/updateUnread/index.ts, so when the user switches between two screens that both use useDocumentTitle (for example HomePage, SearchPage, or ReportScreen), the outgoing screen can clear the title after the incoming screen has already focused. Because the document title is applied asynchronously in updateDocumentTitle(), this leaves the browser tab stuck on CONFIG.SITE_TITLE/New Expensify instead of the new page title, reintroducing the split-pane title race this hook just stopped having.

Useful? React with 👍 / 👎.

Copy link
Contributor

@NikkiWines NikkiWines left a comment

Choose a reason for hiding this comment

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

👍

@mananjadhav
Copy link
Collaborator

Reverting the PR will cause #85352. Hence I was a bit concerned on straight revert.

@yuwenmemon
Copy link
Contributor

AI is going around in circles: #85473

@yuwenmemon
Copy link
Contributor

I think we should move forward with what @MelvinBot proposed here instead: #86087 (comment)

Otherwise, we'll just go back to a point where we cause a different blocker.

@MelvinBot
Copy link
Contributor

I've created a separate draft PR implementing the proposed fix instead of a straight revert: #86142

This adds a clearPageTitle() function that resets the title variable synchronously without triggering updateDocumentTitle(), avoiding both the stale RHP title bug and the "New Expensify" flash from the original cleanup.

Copy link
Contributor

@yuwenmemon yuwenmemon left a comment

Choose a reason for hiding this comment

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

Let's go with the alternative: #86142

Also, I would say this isn't a blocker since it's not a major deviation from the "bugginess" in production

@grgia grgia closed this Mar 24, 2026
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.

6 participants