Skip to content

Commit ba8dcdb

Browse files
committed
udpate code
1 parent 0755455 commit ba8dcdb

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/libs/ReportSecondaryActionUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ function isHoldActionForTransaction(
567567
const isActionOwner = isActionCreator(reportAction);
568568

569569
if (isOpenExpenseReport(report)) {
570-
return isActionOwner;
570+
return isActionOwner && canHoldRequest;
571571
}
572572

573573
if (!iouOrExpenseReport || !canHoldRequest) {

tests/unit/ReportSecondaryActionUtilsTest.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,41 @@ describe('getSecondaryAction', () => {
14921492
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.HOLD)).toBe(false);
14931493
});
14941494

1495+
it('does not include HOLD option for action owner on open expense report when expense is already on hold', () => {
1496+
const report = {
1497+
reportID: REPORT_ID,
1498+
type: CONST.REPORT.TYPE.EXPENSE,
1499+
ownerAccountID: EMPLOYEE_ACCOUNT_ID,
1500+
stateNum: CONST.REPORT.STATE_NUM.OPEN,
1501+
statusNum: CONST.REPORT.STATUS_NUM.OPEN,
1502+
} as unknown as Report;
1503+
1504+
const transaction = {
1505+
transactionID: 'TRANSACTION_ID_R14932',
1506+
comment: {
1507+
hold: 'REPORT_ACTION_ID',
1508+
},
1509+
} as unknown as Transaction;
1510+
const policy = {} as unknown as Policy;
1511+
1512+
jest.spyOn(ReportUtils, 'canHoldUnholdReportAction').mockReturnValueOnce({canHoldRequest: false, canUnholdRequest: true});
1513+
jest.spyOn(ReportUtils, 'isActionCreator').mockReturnValue(true);
1514+
jest.spyOn(ReportActionsUtils, 'getOneTransactionThreadReportID').mockReturnValueOnce(originalMessageR14932.IOUTransactionID);
1515+
const result = getSecondaryReportActions({
1516+
currentUserLogin: EMPLOYEE_EMAIL,
1517+
currentUserAccountID: EMPLOYEE_ACCOUNT_ID,
1518+
report,
1519+
chatReport,
1520+
reportTransactions: [transaction],
1521+
originalTransaction: {} as Transaction,
1522+
violations: {},
1523+
bankAccountList: {},
1524+
policy,
1525+
reportActions: [actionR14932],
1526+
});
1527+
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.HOLD)).toBe(false);
1528+
});
1529+
14951530
it('does not include CHANGE_WORKSPACE option for submitted IOU report and manager being the payer of the new policy', async () => {
14961531
const report = {
14971532
reportID: REPORT_ID,

0 commit comments

Comments
 (0)