Skip to content

Commit

Permalink
use isCancelledIOU and remove redundant function
Browse files Browse the repository at this point in the history
  • Loading branch information
getusha committed Nov 30, 2023
1 parent 2bbd0ef commit 555ddcb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
5 changes: 2 additions & 3 deletions src/components/ReportActionItem/MoneyRequestPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ function MoneyRequestPreview(props) {
const isDistanceRequest = TransactionUtils.isDistanceRequest(props.transaction);
const isExpensifyCardTransaction = TransactionUtils.isExpensifyCardTransaction(props.transaction);
const isSettled = ReportUtils.isSettled(props.iouReport.reportID);
const isCancelled = ReportActionsUtils.isReimbursementDeQueued(props.iouReport.reportID);
const isDeleted = lodashGet(props.action, 'pendingAction', null) === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;

// Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan
Expand Down Expand Up @@ -221,7 +220,7 @@ function MoneyRequestPreview(props) {
message += ` • ${props.translate('iou.approved')}`;
} else if (props.iouReport.isWaitingOnBankAccount) {
message += ` • ${props.translate('iou.pending')}`;
} else if (isCancelled) {
} else if (props.iouReport.isCancelledIOU) {
message += ` • ${props.translate('iou.canceled')}`;
}
return message;
Expand Down Expand Up @@ -283,7 +282,7 @@ function MoneyRequestPreview(props) {
<View style={styles.moneyRequestPreviewBoxText}>
<View style={[styles.flexRow]}>
<Text style={[styles.textLabelSupporting, styles.flex1, styles.lh20, styles.mb1]}>
{getPreviewHeaderText() + (isSettled && !isCancelled ? ` • ${getSettledMessage()}` : '')}
{getPreviewHeaderText() + (isSettled && !props.iouReport.isCancelledIOU ? ` • ${getSettledMessage()}` : '')}
</Text>
{hasFieldErrors && (
<Icon
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyRequestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor

// Flags for allowing or disallowing editing a money request
const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID);
const isCancelled = ReportActionsUtils.isReimbursementDeQueued(moneyRequestReport.reportID);
const isCancelled = moneyRequestReport && moneyRequestReport.isCancelledIOU;
const canEdit = ReportUtils.canEditMoneyRequest(parentReportAction);
const canEditAmount = canEdit && !isSettled && !isCardTransaction;

Expand Down
13 changes: 0 additions & 13 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,6 @@ function isChannelLogMemberAction(reportAction: OnyxEntry<ReportAction>) {
);
}

/**
* Returns whether the report is dequeued only using reportID
*/
function isReimbursementDeQueued(reportID: string): boolean {
if (!allReportActions) {
return false;
}

const reportAction = Object.values(allReportActions[`${reportID}`] ?? {});
return reportAction.some((action) => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED);
}

function isReimbursementDeQueuedAction(reportAction: OnyxEntry<ReportAction>): boolean {
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED;
}
Expand Down Expand Up @@ -714,7 +702,6 @@ export {
hasRequestFromCurrentAccount,
getFirstVisibleReportActionID,
isChannelLogMemberAction,
isReimbursementDeQueued,
isReimbursementDeQueuedAction,
};

Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ function getMoneyRequestReportName(report: OnyxEntry<Report>, policy: OnyxEntry<
return `${payerPaidAmountMessage}${Localize.translateLocal('iou.pending')}`;
}

if (report?.reportID && ReportActionsUtils.isReimbursementDeQueued(report.reportID)) {
if (report?.isCancelledIOU) {
return `${payerPaidAmountMessage}${Localize.translateLocal('iou.canceled')}`;
}

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 @@ -118,6 +118,9 @@ type Report = {
/** Whether the report is waiting on a bank account */
isWaitingOnBankAccount?: boolean;

/** Whether the report is cancelled */
isCancelledIOU?: boolean;

/** Whether the last message was deleted */
isLastMessageDeletedParentAction?: boolean;

Expand Down

0 comments on commit 555ddcb

Please sign in to comment.