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 header displays skeleton when creating report with invalid user #39585

Merged
merged 3 commits into from
Apr 9, 2024
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
15 changes: 10 additions & 5 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,6 @@ function openReport(
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: settledPersonalDetails,
});
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: settledPersonalDetails,
});

// Add the createdReportActionID parameter to the API call
parameters.createdReportActionID = optimisticCreatedAction.reportActionID;
Expand Down Expand Up @@ -1943,6 +1938,16 @@ function deleteReport(reportID: string) {

Onyx.multiSet(onyxData);

// Clear the optimistic personal detail
const participantPersonalDetails: OnyxCollection<PersonalDetails> = {};
report?.participantAccountIDs?.forEach((accountID) => {
if (!allPersonalDetails?.[accountID]?.isOptimisticPersonalDetail) {
return;
}
participantPersonalDetails[accountID] = null;
});
Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, participantPersonalDetails);

// Delete linked IOU report
if (report?.iouReportID) {
deleteReport(report.iouReportID);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/report/ReportActionItemCreated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default withOnyx<ReportActionItemCreatedProps, ReportActionItemCreatedOny
prevProps.report?.description === nextProps.report?.description &&
prevProps.personalDetails === nextProps.personalDetails &&
prevProps.policy?.description === nextProps.policy?.description &&
prevProps.report?.reportName === nextProps.report?.reportName,
prevProps.report?.reportName === nextProps.report?.reportName &&
prevProps.report?.errorFields === nextProps.report?.errorFields,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jayeshmangwani We should add the errorFields to memo function. If not, the error doesn't appear immediately because we don't clear personal detail in failure data, it leads personalDetails doesn't change.

),
);
Loading