Skip to content

Commit

Permalink
Merge pull request #38397 from rayane-djouah/Fix--Scan---After-upload…
Browse files Browse the repository at this point in the history
…ing-a-corrupted-file,-user-needs-to-dismiss-error-from-2-reports

Fix: Scan- After uploading a corrupted file, user needs to dismiss error from 2 reports
  • Loading branch information
MonilBhavsar authored Mar 20, 2024
2 parents f4d3c18 + 5d0e6b4 commit 55410f5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ function ReportPreview({

const hasReceipts = transactionsWithReceipts.length > 0;
const isScanning = hasReceipts && areAllRequestsBeingSmartScanned;
const hasErrors = hasMissingSmartscanFields || (canUseViolations && ReportUtils.hasViolations(iouReportID, transactionViolations));
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const hasErrors = hasMissingSmartscanFields || (canUseViolations && ReportUtils.hasViolations(iouReportID, transactionViolations)) || ReportUtils.hasActionsWithErrors(iouReportID);
const lastThreeTransactionsWithReceipts = transactionsWithReceipts.slice(-3);
const lastThreeReceipts = lastThreeTransactionsWithReceipts.map((transaction) => ReceiptUtils.getThumbnailAndImageURIs(transaction));

Expand Down
9 changes: 9 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5331,6 +5331,14 @@ function shouldCreateNewMoneyRequestReport(existingIOUReport: OnyxEntry<Report>
return !existingIOUReport || hasIOUWaitingOnCurrentUserBankAccount(chatReport) || !canAddOrDeleteTransactions(existingIOUReport);
}

/**
* Checks if report contains actions with errors
*/
function hasActionsWithErrors(reportID: string): boolean {
const reportActions = ReportActionsUtils.getAllReportActions(reportID ?? '');
return Object.values(reportActions ?? {}).some((action) => !isEmptyObject(action.errors));
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
Expand Down Expand Up @@ -5541,6 +5549,7 @@ export {
isJoinRequestInAdminRoom,
canAddOrDeleteTransactions,
shouldCreateNewMoneyRequestReport,
hasActionsWithErrors,
};

export type {
Expand Down
25 changes: 0 additions & 25 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,31 +740,6 @@ function buildOnyxDataForMoneyRequest(
pendingFields: clearedPendingFields,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
...(isNewChatReport
? {
[chatCreatedAction.reportActionID]: {
// Disabling this line since transaction.filename can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
errors: getReceiptError(transaction?.receipt, transaction.filename || transaction.receipt?.filename, isScanRequest),
},
[reportPreviewAction.reportActionID]: {
errors: ErrorUtils.getMicroSecondOnyxError(null),
},
}
: {
[reportPreviewAction.reportActionID]: {
created: reportPreviewAction.created,
// Disabling this line since transaction.filename can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
errors: getReceiptError(transaction?.receipt, transaction.filename || transaction.receipt?.filename, isScanRequest),
},
}),
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`,
Expand Down

0 comments on commit 55410f5

Please sign in to comment.