Skip to content

Commit

Permalink
Merge pull request #54370 from Expensify/cmartins-fixReview
Browse files Browse the repository at this point in the history
Change errors key
  • Loading branch information
madmax330 authored Jan 2, 2025
2 parents 629220d + 6023f99 commit 683a450
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/components/SelectionList/Search/ReportListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ function ReportListItem<TItem extends ListItem>({
canSelectMultiple,
onCheckboxPress,
onSelectRow,
onDismissError,
onFocus,
onLongPressRow,
shouldSyncFocus,
Expand Down Expand Up @@ -132,7 +131,6 @@ function ReportListItem<TItem extends ListItem>({
canSelectMultiple={canSelectMultiple}
onCheckboxPress={() => onCheckboxPress?.(transactionItem as unknown as TItem)}
onSelectRow={onSelectRow}
onDismissError={onDismissError}
onFocus={onFocus}
onLongPressRow={onLongPressRow}
shouldSyncFocus={shouldSyncFocus}
Expand All @@ -153,8 +151,6 @@ function ReportListItem<TItem extends ListItem>({
canSelectMultiple={canSelectMultiple}
onSelectRow={onSelectRow}
onLongPressRow={onLongPressRow}
onDismissError={onDismissError}
errors={item.errors}
pendingAction={item.pendingAction}
keyForList={item.keyForList}
onFocus={onFocus}
Expand Down
3 changes: 0 additions & 3 deletions src/components/SelectionList/Search/TransactionListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function TransactionListItem<TItem extends ListItem>({
canSelectMultiple,
onSelectRow,
onCheckboxPress,
onDismissError,
onFocus,
onLongPressRow,
shouldSyncFocus,
Expand Down Expand Up @@ -65,8 +64,6 @@ function TransactionListItem<TItem extends ListItem>({
showTooltip={showTooltip}
canSelectMultiple={canSelectMultiple}
onSelectRow={onSelectRow}
onDismissError={onDismissError}
errors={item.errors}
pendingAction={item.pendingAction}
keyForList={item.keyForList}
onFocus={onFocus}
Expand Down
3 changes: 3 additions & 0 deletions src/libs/DebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ function validateReportDraftProperty(key: keyof Report, value: string) {
);
case 'errorFields':
return validateObject<ObjectElement<Report, 'errorFields', string>>(value, {}, 'string');
case 'errors':
return validateObject<ObjectElement<Report, 'errors'>>(value, {});
case 'privateNotes':
return validateObject<ObjectElement<Report, 'privateNotes', number>>(
value,
Expand Down Expand Up @@ -624,6 +626,7 @@ function validateReportDraftProperty(key: keyof Report, value: string) {
reimbursed: CONST.RED_BRICK_ROAD_PENDING_ACTION,
preview: CONST.RED_BRICK_ROAD_PENDING_ACTION,
welcomeMessage: CONST.RED_BRICK_ROAD_PENDING_ACTION,
errors: CONST.RED_BRICK_ROAD_PENDING_ACTION,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function getAction(data: OnyxTypes.SearchResults['data'], key: string): SearchTr

// We need to check both options for a falsy value since the transaction might not have an error but the report associated with it might
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (transaction?.hasError || report.hasError) {
if (transaction?.errors || report?.errors) {
return CONST.SEARCH.ACTION_TYPES.REVIEW;
}

Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7111,6 +7111,7 @@ function getPayMoneyRequestParams(
reimbursed: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
partial: full ? null : CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
errors: null,
},
},
{
Expand All @@ -7134,6 +7135,7 @@ function getPayMoneyRequestParams(
reimbursed: null,
partial: null,
},
errors: null,
},
});

Expand Down
5 changes: 3 additions & 2 deletions src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as API from '@libs/API';
import type {ExportSearchItemsToCSVParams, SubmitReportParams} from '@libs/API/parameters';
import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import * as ApiUtils from '@libs/ApiUtils';
import * as ErrorUtils from '@libs/ErrorUtils';
import fileDownload from '@libs/fileDownload';
import enhanceParameters from '@libs/Network/enhanceParameters';
import {rand64} from '@libs/NumberUtils';
Expand Down Expand Up @@ -299,7 +300,7 @@ function approveMoneyRequestOnSearch(hash: number, reportIDList: string[], trans
},
];
const optimisticData: OnyxUpdate[] = createOnyxData({isActionLoading: true});
const failureData: OnyxUpdate[] = createOnyxData({hasError: true});
const failureData: OnyxUpdate[] = createOnyxData({errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')});
const finallyData: OnyxUpdate[] = createOnyxData({isActionLoading: false});

API.write(WRITE_COMMANDS.APPROVE_MONEY_REQUEST_ON_SEARCH, {hash, reportIDList}, {optimisticData, failureData, finallyData});
Expand All @@ -319,7 +320,7 @@ function payMoneyRequestOnSearch(hash: number, paymentData: PaymentData[], trans
];

const optimisticData: OnyxUpdate[] = createOnyxData({isActionLoading: true});
const failureData: OnyxUpdate[] = createOnyxData({hasError: true});
const failureData: OnyxUpdate[] = createOnyxData({errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')});
const finallyData: OnyxUpdate[] = createOnyxData({isActionLoading: false});

// eslint-disable-next-line rulesdir/no-api-side-effects-method
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback<
/** Collection of errors that exist in report fields */
errorFields?: OnyxCommon.ErrorFields;

/** Errors used by Search to show RBR */
errors?: OnyxCommon.Errors;

/** Whether the report is waiting on a bank account */
isWaitingOnBankAccount?: boolean;

Expand Down
5 changes: 3 additions & 2 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type TransactionListItem from '@components/SelectionList/Search/Transacti
import type {ReportActionListItemType, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types';
import type CONST from '@src/CONST';
import type ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxCommon from './OnyxCommon';
import type {ACHAccount, ApprovalRule, ExpenseRule} from './Policy';
import type {InvoiceReceiver, Participants} from './Report';
import type ReportActionName from './ReportActionName';
Expand Down Expand Up @@ -156,7 +157,7 @@ type SearchReport = {
isActionLoading?: boolean;

/** Whether the report has violations or errors */
hasError?: boolean;
errors?: OnyxCommon.Errors;

/** Collection of report participants, indexed by their accountID */
participants?: Participants;
Expand Down Expand Up @@ -367,7 +368,7 @@ type SearchTransaction = {
isActionLoading?: boolean;

/** Whether the transaction has violations or errors */
hasError?: boolean;
errors?: OnyxCommon.Errors;
};

/** Types of searchable transactions */
Expand Down
1 change: 1 addition & 0 deletions src/types/utils/whitelistedReportKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback<
unheldNonReimbursableTotal: unknown;
currency: unknown;
errorFields: unknown;
errors: unknown;
isWaitingOnBankAccount: unknown;
isCancelledIOU: unknown;
iouReportID: unknown;
Expand Down

0 comments on commit 683a450

Please sign in to comment.