Skip to content

Commit 79bea3b

Browse files
authored
Merge pull request Expensify#74162 from nkdengineer/fix/73620
2 parents 5d3d7ef + 7f4a37c commit 79bea3b

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

src/libs/actions/IOU.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import Performance from '@libs/Performance';
8181
import {getAccountIDsByLogins, getLoginByAccountID} from '@libs/PersonalDetailsUtils';
8282
import {addSMSDomainIfPhoneNumber} from '@libs/PhoneNumber';
8383
import {
84+
arePaymentsEnabled,
8485
getDistanceRateCustomUnit,
8586
getDistanceRateCustomUnitRate,
8687
getMemberAccountIDsForWorkspace,
@@ -10308,7 +10309,8 @@ function canIOUBePaid(
1030810309
!isChatReportArchived &&
1030910310
!isAutoReimbursable &&
1031010311
(!shouldBeApproved || !shouldCheckApprovedState) &&
10311-
!isPayAtEndExpenseReport
10312+
!isPayAtEndExpenseReport &&
10313+
(!isExpenseReport(iouReport) || arePaymentsEnabled(policy as OnyxEntry<OnyxTypes.Policy>))
1031210314
);
1031310315
}
1031410316

src/libs/actions/Report.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,16 @@ import Parser from '@libs/Parser';
8686
import {getParsedMessageWithShortMentions} from '@libs/ParsingUtils';
8787
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
8888
import * as PhoneNumber from '@libs/PhoneNumber';
89-
import {getDefaultApprover, getMemberAccountIDsForWorkspace, getPolicy, isPaidGroupPolicy, isPolicyAdmin as isPolicyAdminPolicyUtils, isPolicyMember} from '@libs/PolicyUtils';
89+
import {
90+
getDefaultApprover,
91+
getMemberAccountIDsForWorkspace,
92+
getPolicy,
93+
isInstantSubmitEnabled,
94+
isPaidGroupPolicy,
95+
isPolicyAdmin as isPolicyAdminPolicyUtils,
96+
isPolicyMember,
97+
isSubmitAndClose,
98+
} from '@libs/PolicyUtils';
9099
import processReportIDDeeplink from '@libs/processReportIDDeeplink';
91100
import Pusher from '@libs/Pusher';
92101
import type {UserIsLeavingRoomEvent, UserIsTypingEvent} from '@libs/Pusher/types';
@@ -5639,6 +5648,30 @@ function buildOptimisticChangePolicyData(
56395648
});
56405649
}
56415650

5651+
const isInstantSubmitEnabledLocal = isInstantSubmitEnabled(policy);
5652+
const isSubmitAndCloseLocal = isSubmitAndClose(policy);
5653+
const arePaymentsDisabled = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;
5654+
if (isProcessingReport(report) && isInstantSubmitEnabledLocal && isSubmitAndCloseLocal && arePaymentsDisabled) {
5655+
newStatusNum = CONST.REPORT.STATUS_NUM.CLOSED;
5656+
optimisticData.push({
5657+
onyxMethod: Onyx.METHOD.MERGE,
5658+
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
5659+
value: {
5660+
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
5661+
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
5662+
},
5663+
});
5664+
5665+
failureData.push({
5666+
onyxMethod: Onyx.METHOD.MERGE,
5667+
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
5668+
value: {
5669+
stateNum: report.stateNum,
5670+
statusNum: report.statusNum,
5671+
},
5672+
});
5673+
}
5674+
56425675
if (newStatusNum) {
56435676
// buildOptimisticNextStep is used in parallel
56445677
// eslint-disable-next-line @typescript-eslint/no-deprecated

tests/actions/IOUTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6645,7 +6645,7 @@ describe('actions/IOU', () => {
66456645
id: 'AA',
66466646
type: CONST.POLICY.TYPE.TEAM,
66476647
approvalMode: CONST.POLICY.APPROVAL_MODE.BASIC,
6648-
reimbursementChoice: CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO,
6648+
reimbursementChoice: CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES,
66496649
role: CONST.POLICY.ROLE.ADMIN,
66506650
};
66516651

0 commit comments

Comments
 (0)