Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA failed: do not check this off] fix: Submit expense option is not disabled for users who are invited to expense report #47373

Merged
merged 4 commits into from
Aug 15, 2024
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
8 changes: 8 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,14 @@ function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): bool
return false;
}

if (isIOUReport(moneyRequestReport) && currentUserAccountID !== moneyRequestReport?.managerID && currentUserAccountID !== moneyRequestReport?.ownerAccountID) {
return false;
}

if (isExpenseReport(moneyRequestReport) && currentUserAccountID !== moneyRequestReport?.managerID) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this break Instant Submit report where submitters create an expense and it gets added to a processing report?

Copy link
Contributor

@youssef-lr youssef-lr Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this breaks optimistic data for instant submit, we end up creating a new stale preview, but the backend adds the expense to the processing report

Screen.Recording.2024-08-16.at.22.24.26.mov

return false;
}

const policy = getPolicy(moneyRequestReport?.policyID);
if (PolicyUtils.isInstantSubmitEnabled(policy) && PolicyUtils.isSubmitAndClose(policy) && hasOnlyNonReimbursableTransactions(moneyRequestReport?.reportID)) {
return false;
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ describe('ReportUtils', () => {
type: CONST.REPORT.TYPE.IOU,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
managerID: currentUserAccountID,
};
const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs[0]]);
expect(moneyRequestOptions.length).toBe(1);
Expand All @@ -573,6 +574,7 @@ describe('ReportUtils', () => {
type: CONST.REPORT.TYPE.IOU,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
managerID: currentUserAccountID,
};
const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs[0]]);
expect(moneyRequestOptions.length).toBe(1);
Expand All @@ -591,6 +593,7 @@ describe('ReportUtils', () => {
...LHNTestUtils.getFakeReport(),
parentReportID: '102',
type: CONST.REPORT.TYPE.EXPENSE,
managerID: currentUserAccountID,
};
const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]);
expect(moneyRequestOptions.length).toBe(2);
Expand All @@ -611,6 +614,7 @@ describe('ReportUtils', () => {
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS_NUM.OPEN,
parentReportID: '103',
managerID: currentUserAccountID,
};
const paidPolicy = {
type: CONST.POLICY.TYPE.TEAM,
Expand All @@ -634,6 +638,7 @@ describe('ReportUtils', () => {
type: CONST.REPORT.TYPE.IOU,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
managerID: currentUserAccountID,
};
const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs[0]]);
expect(moneyRequestOptions.length).toBe(1);
Expand All @@ -646,6 +651,7 @@ describe('ReportUtils', () => {
type: CONST.REPORT.TYPE.IOU,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
managerID: currentUserAccountID,
};
const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs[0]]);
expect(moneyRequestOptions.length).toBe(1);
Expand Down Expand Up @@ -679,6 +685,7 @@ describe('ReportUtils', () => {
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
parentReportID: '101',
policyID: paidPolicy.id,
managerID: currentUserAccountID,
};
const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs[0]]);
expect(moneyRequestOptions.length).toBe(2);
Expand Down
Loading