Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ import {
hasDependentTags as hasDependentTagsPolicyUtils,
hasDynamicExternalWorkflow,
isExpensifyTeam,
isGroupPolicy as isGroupPolicyPolicyUtils,
isInstantSubmitEnabled,
isPaidGroupPolicy as isPaidGroupPolicyPolicyUtils,
isPendingDeletePolicy,
Expand Down Expand Up @@ -2785,7 +2786,7 @@ function canAddTransaction(moneyRequestReport: OnyxEntry<Report>, isReportArchiv
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
const policy = getPolicy(moneyRequestReport?.policyID);

if (isExpenseReport(moneyRequestReport) && (!isCurrentUserSubmitter(moneyRequestReport) || !isPaidGroupPolicyPolicyUtils(policy))) {
if (isExpenseReport(moneyRequestReport) && (!isCurrentUserSubmitter(moneyRequestReport) || !isGroupPolicyPolicyUtils(policy))) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions tests/actions/IOU/RequestMoneyTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ jest.mock('@src/libs/SearchQueryUtils', () => {
jest.mock('@libs/PolicyUtils', () => ({
...jest.requireActual<typeof PolicyUtils>('@libs/PolicyUtils'),
isPaidGroupPolicy: jest.fn().mockReturnValue(true),
isGroupPolicy: jest.fn().mockReturnValue(true),
isPolicyOwner: jest.fn().mockImplementation((policy?: OnyxEntry<Policy>, currentUserAccountID?: number) => !!currentUserAccountID && policy?.ownerAccountID === currentUserAccountID),
}));

Expand Down
1 change: 1 addition & 0 deletions tests/actions/ReportPreviewActionUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jest.mock('@libs/PolicyUtils', () => ({
hasAccountingConnections: jest.fn().mockReturnValue(true),
getValidConnectedIntegration: jest.fn().mockReturnValue('netsuite'),
isPaidGroupPolicy: jest.fn().mockReturnValue(true),
isGroupPolicy: jest.fn().mockReturnValue(true),
}));
jest.mock('@src/libs/SearchUIUtils', () => ({
getSuggestedSearches: jest.fn().mockReturnValue({}),
Expand Down
1 change: 1 addition & 0 deletions tests/unit/ReportSecondaryActionUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jest.mock('@libs/PolicyUtils', () => ({
isPolicyAuditor: (...args: Parameters<typeof PolicyUtils.isPolicyAuditor>) => jest.requireActual<typeof PolicyUtils>('@libs/PolicyUtils').isPolicyAuditor(...args),
getValidConnectedIntegration: jest.fn().mockReturnValue('netsuite'),
isPaidGroupPolicy: jest.fn().mockReturnValue(true),
isGroupPolicy: jest.fn().mockReturnValue(true),
}));

describe('getSecondaryAction', () => {
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ jest.mock('@libs/PolicyUtils', () => ({
...jest.requireActual<typeof PolicyUtils>('@libs/PolicyUtils'),
isPolicyAdmin: jest.fn().mockImplementation((policy?: Policy) => policy?.role === 'admin'),
isPaidGroupPolicy: jest.fn().mockImplementation((policy?: Policy) => policy?.type === 'corporate' || policy?.type === 'team'),
isGroupPolicy: jest.fn().mockImplementation((policy?: Policy) => policy?.type === 'corporate' || policy?.type === 'team' || policy?.type === 'submit2026'),
isPolicyOwner: jest.fn().mockImplementation((policy?: Policy, currentUserAccountID?: number) => !!currentUserAccountID && policy?.ownerAccountID === currentUserAccountID),
}));

Expand Down Expand Up @@ -3906,6 +3907,7 @@ describe('ReportUtils', () => {
ownerAccountID: currentUserAccountID,
};
mockedPolicyUtils.isPaidGroupPolicy.mockReturnValue(true);
mockedPolicyUtils.isGroupPolicy.mockReturnValue(true);
const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]);
expect(moneyRequestOptions.length).toBe(2);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true);
Expand Down Expand Up @@ -8723,6 +8725,7 @@ describe('ReportUtils', () => {
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report);

mockedPolicyUtils.isPaidGroupPolicy.mockReturnValue(true);
mockedPolicyUtils.isGroupPolicy.mockReturnValue(true);

// When it's checked if the transactions can be added
// Simulate how components determined if a report is archived by using this hook
Expand Down Expand Up @@ -8789,6 +8792,7 @@ describe('ReportUtils', () => {
const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.reportID));

mockedPolicyUtils.isPaidGroupPolicy.mockReturnValue(true);
mockedPolicyUtils.isGroupPolicy.mockReturnValue(true);

// If the canAddTransaction is used for the case of adding expense into the report
const result = canAddTransaction(report, isReportArchived.current);
Expand Down
Loading