Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web/mWeb - The public room disappears after log-in with a new Gmail account #58494

Open
1 of 8 tasks
lanitochka17 opened this issue Mar 14, 2025 · 3 comments
Open
1 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Overdue

Comments

@lanitochka17
Copy link

lanitochka17 commented Mar 14, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.1.13-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5740326&group_by=cases:section_id&group_order=asc&group_id=229066
Issue reported by: Applause - Internal Team

Action Performed:

  1. Login with a New Gmail Account
  2. Log out of New Expensify
  3. Navigate to this link - https://staging.new.expensify.com/r/2091104345528462
  4. Verify you can see the room as an anonymous user
  5. Click on Sign In or any other action that should not be allowed to an unauthenticated user
  6. Log in with a new account

Expected Result:

Verify you can see the public room in the LHN

Actual Result:

After login, the public room disappear until refresh the page

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6770709_1741963958131.PublicRoom.mp4

View all open jobs on GitHub

@lanitochka17 lanitochka17 added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Mar 14, 2025
Copy link

melvin-bot bot commented Mar 14, 2025

Triggered auto assignment to @Christinadobrzyn (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@FitseTLT
Copy link
Contributor

FitseTLT commented Mar 14, 2025

Proposal

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

Web/mWeb - The public room disappears after log-in with a new Gmail account

What is the root cause of that problem?

While on the public room and signing up the public report will be cleared from onyx when OpenApp sets the report collection to only include concierge chat. In case of sign in the OpenApp sets the reports linked to the account but in this case as it is a sign up flow it only returns concierge chat report.
Then this effect runs that will navigate it to concierge chat

const isTopLevelPolicyRoomWithNoStatus = !report?.statusNum && !prevReport?.parentReportID && prevReport?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ROOM;
const isClosedTopLevelPolicyRoom = wasReportRemoved && prevReport.statusNum === CONST.REPORT.STATUS_NUM.OPEN && isTopLevelPolicyRoomWithNoStatus;
// Navigate to the Concierge chat if the room was removed from another device (e.g. user leaving a room or removed from a room)
if (
// non-optimistic case
(!prevUserLeavingStatus && !!userLeavingStatus) ||
didReportClose ||
isRemovalExpectedForReportType ||
isClosedTopLevelPolicyRoom ||
(prevDeletedParentAction && !deletedParentAction)
) {
// Early return if the report we're passing isn't in a focused state. We only want to navigate to Concierge if the user leaves the room from another device or gets removed from the room while the report is in a focused state.
// Prevent auto navigation for report in RHP
if (!isFocused || isInNarrowPaneModal) {
return;
}
Navigation.dismissModal();
if (Navigation.getTopmostReportId() === prevOnyxReportID) {
Navigation.setShouldPopAllStateOnUP(true);
Navigation.goBack(undefined, {shouldPopToTop: true});
}
if (prevReport?.parentReportID) {
// Prevent navigation to the IOU/Expense Report if it is pending deletion.
if (isMoneyRequestReportPendingDeletion(prevReport.parentReportID)) {
return;
}
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));
return;
}
navigateToConciergeChat();
return;
}

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

The effect's purpose is to navigate the user away from a room if the room was removed from another device (e.g. user leaving a room or removed from a room) so it should not act for public rooms as the user is not required to be a member of public rooms to access it so Change

const isTopLevelPolicyRoomWithNoStatus = !report?.statusNum && !prevReport?.parentReportID && prevReport?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ROOM;

  const isTopLevelPolicyRoomWithNoStatus =
            !report?.statusNum && !prevReport?.parentReportID && prevReport?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ROOM && prevReport.visibility !== 'public';
        

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N / A - navigation bug

What alternative solutions did you explore? (Optional)

@daledah
Copy link
Contributor

daledah commented Mar 15, 2025

Proposal

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

After login, the public room disappear until refresh the page

What is the root cause of that problem?

In the sign-in modal, after a user successfully logs in, the app dismisses the modal and calls the OpenApp API:

App.openApp();

The OpenApp API response replaces the current reports collection with fresh data from the backend. This overwrites any public report data the user accessed before logging in.

On the report screen, the app attempts to render the current public report. However, because the OpenApp response removed the public room data, the app redirects the user to the Concierge screen:

navigateToConciergeChat();

As a result, the public room disappears, and the Concierge screen opens instead.

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

To fix the issue, we can cache the accessed public room data before the user logs in. After the OpenApp API response merges into Onyx, we then restore the cached data.

  1. Update the getOnyxDataForOpenOrReconnect function
    In this function:
    function getOnyxDataForOpenOrReconnect(isOpenApp = false, isFullReconnect = false): OnyxData {

Add a new shouldKeepPublicRooms flag to handle public room caching:

+ function getOnyxDataForOpenOrReconnect(isOpenApp = false, isFullReconnect = false, shouldKeepPublicRooms = false): OnyxData {
...
+    if (shouldKeepPublicRooms) {
+        const publicReports = Object.values(allReports ?? {}).filter((report) => isPublicRoom(report) && isValidReport(report));
+        publicReports?.forEach((report) => {
+            result.successData?.push({
+                onyxMethod: Onyx.METHOD.MERGE,
+                key: `${ONYXKEYS.COLLECTION.REPORT}${report?.reportID}`,
+                value: {
+                    ...report,
+                },
+            });
+        });
+    }
...
}

This ensures public rooms remain after the API call updates Onyx.

  1. Modify the SignInModal.tsx call
    In the sign-in modal, pass the shouldKeepPublicRooms flag to App.openApp:
    App.openApp();
App.openApp(true);
  1. Adjust the openApp function to support the new flag
    Finally, update the openApp function to accept and forward the shouldKeepPublicRooms parameter:

    App/src/libs/actions/App.ts

    Lines 293 to 296 in ebbc565

    function openApp() {
    return getPolicyParamsForOpenOrReconnect().then((policyParams: PolicyParamsForOpenOrReconnect) => {
    const params: OpenAppParams = {enablePriorityModeFilter: true, ...policyParams};
    return API.write(WRITE_COMMANDS.OPEN_APP, params, getOnyxDataForOpenOrReconnect(true), {
function openApp(shouldKeepPublicRooms = false) {
    return getPolicyParamsForOpenOrReconnect().then((policyParams: PolicyParamsForOpenOrReconnect) => {
        const params: OpenAppParams = {enablePriorityModeFilter: true, ...policyParams};
        return API.write(WRITE_COMMANDS.OPEN_APP, params, getOnyxDataForOpenOrReconnect(true, undefined, shouldKeepPublicRooms), {

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

  1. Mock Public Rooms:
  • Set up multiple public rooms in the initial Onyx data.
  1. Trigger OpenApp:
  • Call OpenApp with the shouldKeepPublicRooms flag enabled.
  1. Verify Onyx Data:
  • Ensure all previously mocked public rooms still exist in Onyx after the API call and that their data remains unchanged.

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Overdue
Projects
None yet
Development

No branches or pull requests

4 participants