Skip to content
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
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
*/

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 218 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -231,7 +231,7 @@
const deprecatedCachedOneTransactionThreadReportIDs: Record<string, string | undefined> = {};
/** @deprecated Use sortedReportActionsData from ONYXKEYS.DERIVED.RAM_ONLY_SORTED_REPORT_ACTIONS instead. Will be removed once all flows are migrated. */
let deprecatedAllReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 234 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -281,7 +281,7 @@
});

let activePolicyID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 284 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
callback: (value) => (activePolicyID = value),
});
Expand Down Expand Up @@ -821,7 +821,7 @@
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) {
lastMessageTextFromReport = getExportIntegrationLastMessageText(translate, lastReportAction);
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RECEIPT_SCAN_FAILED) {
lastMessageTextFromReport = translate('iou.receiptScanningFailed');
lastMessageTextFromReport = getReportActionMessageText(lastReportAction) || translate('iou.receiptScanningFailed');
} else if (lastReportAction?.actionName && isOldDotReportAction(lastReportAction)) {
lastMessageTextFromReport = getMessageOfOldDotReportAction(translate, lastReportAction, false);
} else if (isActionableJoinRequest(lastReportAction)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getMarkedReimbursedMessage,
getOriginalMessage,
getRemovedFromApprovalChainMessage,
getReportActionMessageText,
getReportActionText,
isActionOfType,
isRejectedAction,
Expand Down Expand Up @@ -88,7 +89,8 @@ function SimpleMessageContent({action}: SimpleMessageContentProps) {
return <ReportActionItemBasicMessage message={translate('violations.resolvedDuplicates')} />;
}
if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.RECEIPT_SCAN_FAILED)) {
return <ReportActionItemBasicMessage message={translate('iou.receiptScanningFailed')} />;
const htmlMessage = getReportActionMessageText(action) || translate('iou.receiptScanningFailed');
return <ReportActionItemBasicMessage message={htmlMessage} />;
}
if (isUnapprovedAction(action)) {
return <ReportActionItemBasicMessage message={translate('iou.unapproved')} />;
Expand Down
28 changes: 23 additions & 5 deletions tests/ui/PureReportActionItemTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -928,11 +928,6 @@ describe('PureReportActionItem', () => {
actionName: CONST.REPORT.ACTIONS.TYPE.RESOLVED_DUPLICATES,
translationKey: 'violations.resolvedDuplicates' as TranslationPaths,
},
{
testTitle: 'RECEIPT_SCAN_FAILED action',
actionName: CONST.REPORT.ACTIONS.TYPE.RECEIPT_SCAN_FAILED,
translationKey: 'iou.receiptScanningFailed' as TranslationPaths,
},
{
testTitle: 'UNAPPROVED action',
actionName: CONST.REPORT.ACTIONS.TYPE.UNAPPROVED,
Expand All @@ -958,6 +953,29 @@ describe('PureReportActionItem', () => {
expect(screen.getByText(translateLocal(translationKey))).toBeOnTheScreen();
});

it('RECEIPT_SCAN_FAILED action shows message from action data', async () => {
// Given a RECEIPT_SCAN_FAILED message with a html message from server.
// Then verify server message is rendered.
const action = createReportAction(CONST.REPORT.ACTIONS.TYPE.RECEIPT_SCAN_FAILED, {});
action.message = [
{
type: 'COMMENT',
html: "the date couldn't be read from this receipt. Please enter it manually.",
text: "the date couldn't be read from this receipt. Please enter it manually.",
},
];
renderItemWithAction(action);
await waitForBatchedUpdatesWithAct();
expect(screen.getByText("the date couldn't be read from this receipt. Please enter it manually.")).toBeOnTheScreen();

// Given an RECEIPT_SCAN_FAILED with no server side message
// Then verify generic translation phrase is rendered
action.message = [{type: 'COMMENT', html: '', text: ''}];
renderItemWithAction(action);
await waitForBatchedUpdatesWithAct();
expect(screen.getByText(translateLocal('iou.receiptScanningFailed'))).toBeOnTheScreen();
});

it('HOLD_COMMENT action renders via ReportActionItemBasicMessage', async () => {
const action = createReportAction(CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT, {});
action.message = [{type: 'COMMENT', html: 'Hold reason text', text: 'Hold reason text'}];
Expand Down
Loading