Skip to content

Commit

Permalink
Merge pull request #49324 from c3024/correct-last-accessed-report-for…
Browse files Browse the repository at this point in the history
…-new-user

fix last accessed report for new user
  • Loading branch information
bondydaa committed Sep 20, 2024
2 parents 97b51ac + c561af8 commit ee7cdad
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,6 @@ Onyx.connect({
},
});

let isFirstTimeNewExpensifyUser = false;
Onyx.connect({
key: ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER,
callback: (value) => {
isFirstTimeNewExpensifyUser = value ?? false;
},
});

let onboarding: OnyxEntry<Onboarding | []>;
Onyx.connect({
key: ONYXKEYS.NVP_ONBOARDING,
Expand Down Expand Up @@ -1341,26 +1333,13 @@ function findLastAccessedReport(ignoreDomainRooms: boolean, openOnAdminRoom = fa
});
}

if (isFirstTimeNewExpensifyUser) {
// Filter out the systemChat report from the reports list, as we don't want to drop the user into that report over Concierge when they first log in
reportsValues = reportsValues.filter((report) => !isSystemChat(report)) ?? [];
if (reportsValues.length === 1) {
return reportsValues[0];
}
// Filter out the system chat (Expensify chat) because the composer is disabled in it,
// and it prompts the user to use the Concierge chat instead.
reportsValues = reportsValues.filter((report) => !isSystemChat(report)) ?? [];

return adminReport ?? reportsValues.find((report) => !isConciergeChatReport(report));
}

// If we only have two reports and one of them is the system chat, filter it out so we don't
// overwrite showing the concierge chat
const hasSystemChat = reportsValues.find((report) => isSystemChat(report)) ?? false;
if (reportsValues.length === 2 && hasSystemChat) {
reportsValues = reportsValues.filter((report) => !isSystemChat(report)) ?? [];
}

// We are getting the last read report from the metadata of the report.
// At least two reports remain: self DM and Concierge chat.
// Return the most recently visited report. Get the last read report from the report metadata.
const lastRead = getMostRecentlyVisitedReport(reportsValues, allReportMetadata);

return adminReport ?? lastRead;
}

Expand Down

0 comments on commit ee7cdad

Please sign in to comment.