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

Fix page not found appears for a second when user opens a thread #20076

Merged
merged 6 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,16 @@ function getReportName(report) {
return _.map(participantsWithoutCurrentUser, (login) => getDisplayNameForParticipant(login, isMultipleParticipantReport)).join(', ');
}

/**
* Get the report for a reportID
*
* @param {String} reportID
* @returns {Object}
*/
function getReport(reportID) {
return allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
}
Comment on lines +1050 to +1052
Copy link
Contributor

@alitoshmatov alitoshmatov Jun 7, 2023

Choose a reason for hiding this comment

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

This also causing crash if user is not authenticated yet, and does not have any value in onyx. Part of #20394
Screenshot 2023-06-08 at 12 08 35 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch @alitoshmatov

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI this can still return null if the report key is present, but the report was deleted (set to null)


/**
* Navigate to the details page of a given report
*
Expand Down Expand Up @@ -2182,6 +2192,7 @@ export {
getRoomWelcomeMessage,
getDisplayNamesWithTooltips,
getReportName,
getReport,
getReportIDFromLink,
getRouteFromLink,
navigateToDetailsPage,
Expand Down
10 changes: 10 additions & 0 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ function openReport(reportID, participantList = [], newReportObject = {}, parent
params.shouldRetry = false;
}

// If we open an exist report, but it is not present in Onyx yet, we should change the method to set for this report
// and we need data to be available when we navigate to the chat page
if (_.isEmpty(ReportUtils.getReport(reportID))) {
optimisticReportData.onyxMethod = Onyx.METHOD.SET;
optimisticReportData.value = {
...optimisticReportData.value,
reportID: reportID.toString(),
};
}
Comment on lines +385 to +391
Copy link
Contributor

@aldo-expensify aldo-expensify Jun 7, 2023

Choose a reason for hiding this comment

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

This seems to be causing this regression: #20394

If I remove these lines, #20394 is solved.

Copy link
Contributor

Choose a reason for hiding this comment

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

Investigating now

Copy link
Contributor

Choose a reason for hiding this comment

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

@aldo-expensify It looks like setting the reportID optimistically is the root cause of the other issue.


// If we are creating a new report, we need to add the optimistic report data and a report action
if (!_.isEmpty(newReportObject)) {
// Change the method to set for new reports because it doesn't exist yet, is faster,
Expand Down