Skip to content

Commit 81a419e

Browse files
committed
Merge branch 'main' into @chrispader/update-vision-camera-for-android-16kb-memory-page-size-compat
2 parents 311489f + a8175e0 commit 81a419e

7 files changed

Lines changed: 98 additions & 9 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"test:debug": "TZ=utc NODE_OPTIONS='--inspect-brk --experimental-vm-modules' jest --runInBand",
4747
"perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure",
4848
"typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc",
49-
"lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=327 --cache --cache-location=node_modules/.cache/eslint",
49+
"lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=320 --cache --cache-location=node_modules/.cache/eslint",
5050
"lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh",
5151
"lint-watch": "npx eslint-watch --watch --changed",
5252
"shellcheck": "./scripts/shellCheck.sh",

src/libs/ReportUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9818,6 +9818,10 @@ function canLeaveChat(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, isRe
98189818
return true;
98199819
}
98209820

9821+
if (isMoneyRequestReport(report) && currentUserAccountID !== report?.managerID && currentUserAccountID !== report?.ownerAccountID && !isPolicyAdminPolicyUtils(policy)) {
9822+
return true;
9823+
}
9824+
98219825
if (isPublicRoom(report) && isAnonymousUserSession()) {
98229826
return false;
98239827
}

src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,18 @@ function AttachmentPickerWithMenuItems({
233233
const moneyRequestOptionsList = temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? []).map((option) => options[option], isReportArchived);
234234

235235
return moneyRequestOptionsList.flat().filter((item, index, self) => index === self.findIndex((t) => t.text === item.text));
236-
}, [translate, shouldUseNarrowLayout, report, policy, reportParticipantIDs, selectOption, isDelegateAccessRestricted, showDelegateNoAccessModal, isManualDistanceTrackingEnabled]);
236+
}, [
237+
translate,
238+
shouldUseNarrowLayout,
239+
report,
240+
policy,
241+
reportParticipantIDs,
242+
selectOption,
243+
isDelegateAccessRestricted,
244+
showDelegateNoAccessModal,
245+
isManualDistanceTrackingEnabled,
246+
isReportArchived,
247+
]);
237248

238249
const createReportOption: PopoverMenuItem[] = useMemo(() => {
239250
if (!isPolicyExpenseChat(report) || !isPaidGroupPolicy(report) || !isReportOwner(report)) {

src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function ReportActionCompose({
244244
const parentReport = getParentReport(report);
245245
const isSettledOrApproved = isSettled(report) || isSettled(parentReport) || isReportApproved({report}) || isReportApproved({report: parentReport});
246246
return (shouldAddOrReplaceReceipt && !isSettledOrApproved) || !!temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs, isReportArchived).length;
247-
}, [shouldAddOrReplaceReceipt, report, policy, reportParticipantIDs]);
247+
}, [shouldAddOrReplaceReceipt, report, policy, reportParticipantIDs, isReportArchived]);
248248

249249
// Placeholder to display in the chat input.
250250
const inputPlaceholder = useMemo(() => {

src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
129129
const [travelSettings] = useOnyx(ONYXKEYS.NVP_TRAVEL_SETTINGS, {canBeMissing: true});
130130

131131
const canSendInvoice = useMemo(() => canSendInvoicePolicyUtils(allPolicies as OnyxCollection<OnyxTypes.Policy>, session?.email), [allPolicies, session?.email]);
132-
const isArchivedReport = useReportIsArchived(quickActionReport?.reportID);
133-
const isValidReport = !(isEmptyObject(quickActionReport) || isArchivedReport);
132+
const isValidReport = !(isEmptyObject(quickActionReport) || isReportArchived);
134133
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});
135134
const [hasSeenTour = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
136135
selector: hasSeenTourSelector,
@@ -155,16 +154,16 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
155154

156155
const quickActionAvatars = useMemo(() => {
157156
if (isValidReport) {
158-
const avatars = getIcons(quickActionReport, personalDetails, null, undefined, undefined, undefined, undefined, isArchivedReport);
157+
const avatars = getIcons(quickActionReport, personalDetails, null, undefined, undefined, undefined, undefined, isReportArchived);
159158
return avatars.length <= 1 || isPolicyExpenseChat(quickActionReport) ? avatars : avatars.filter((avatar) => avatar.id !== session?.accountID);
160159
}
161160
if (!isEmptyObject(policyChatForActivePolicy)) {
162-
return getIcons(policyChatForActivePolicy, personalDetails, null, undefined, undefined, undefined, undefined, isArchivedReport);
161+
return getIcons(policyChatForActivePolicy, personalDetails, null, undefined, undefined, undefined, undefined, isReportArchived);
163162
}
164163
return [];
165164
// Policy is needed as a dependency in order to update the shortcut details when the workspace changes
166165
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
167-
}, [personalDetails, session?.accountID, quickActionReport, quickActionPolicy, policyChatForActivePolicy]);
166+
}, [personalDetails, session?.accountID, quickActionReport, quickActionPolicy, policyChatForActivePolicy, isReportArchived, isValidReport]);
168167

169168
const quickActionTitle = useMemo(() => {
170169
if (isEmptyObject(quickActionReport)) {
@@ -397,6 +396,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
397396
shouldUseNarrowLayout,
398397
isDelegateAccessRestricted,
399398
showDelegateNoAccessModal,
399+
isReportArchived,
400400
]);
401401

402402
const isTravelEnabled = useMemo(() => {

src/pages/iou/request/MoneyRequestParticipantsSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ function MoneyRequestParticipantsSelector(
462462
const initiateContactImportAndSetState = useCallback(() => {
463463
setContactPermissionState(RESULTS.GRANTED);
464464
InteractionManager.runAfterInteractions(importAndSaveContacts);
465-
}, [importAndSaveContacts]);
465+
}, [importAndSaveContacts, setContactPermissionState]);
466466

467467
const footerContent = useMemo(() => {
468468
if (isDismissed && !shouldShowSplitBillErrorMessage && !participants.length) {

tests/unit/ReportUtilsTest.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4550,6 +4550,80 @@ describe('ReportUtils', () => {
45504550

45514551
expect(canLeaveChat(report, reportPolicy)).toBe(true);
45524552
});
4553+
4554+
describe('when the report is a money report', () => {
4555+
it('should return false for the owner of the report', async () => {
4556+
const report: Report = {
4557+
...createRandomReport(1),
4558+
chatType: undefined,
4559+
type: CONST.REPORT.TYPE.IOU,
4560+
ownerAccountID: currentUserAccountID,
4561+
};
4562+
4563+
await Onyx.set(ONYXKEYS.SESSION, {email: currentUserEmail, accountID: currentUserAccountID});
4564+
4565+
const reportPolicy: Policy = {
4566+
...createRandomPolicy(1),
4567+
role: CONST.POLICY.ROLE.USER,
4568+
};
4569+
4570+
expect(canLeaveChat(report, reportPolicy)).toBe(false);
4571+
});
4572+
4573+
it('should return false for the manager of the report', async () => {
4574+
const report: Report = {
4575+
...createRandomReport(1),
4576+
chatType: undefined,
4577+
type: CONST.REPORT.TYPE.IOU,
4578+
managerID: currentUserAccountID,
4579+
};
4580+
4581+
await Onyx.set(ONYXKEYS.SESSION, {email: currentUserEmail, accountID: currentUserAccountID});
4582+
4583+
const reportPolicy: Policy = {
4584+
...createRandomPolicy(1),
4585+
role: CONST.POLICY.ROLE.USER,
4586+
};
4587+
4588+
expect(canLeaveChat(report, reportPolicy)).toBe(false);
4589+
});
4590+
4591+
it('should return false for the admin of the policy', async () => {
4592+
const report: Report = {
4593+
...createRandomReport(1),
4594+
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
4595+
type: CONST.REPORT.TYPE.EXPENSE,
4596+
};
4597+
4598+
await Onyx.set(ONYXKEYS.SESSION, {email: currentUserEmail, accountID: currentUserAccountID});
4599+
4600+
const reportPolicy: Policy = {
4601+
...createRandomPolicy(1),
4602+
role: CONST.POLICY.ROLE.ADMIN,
4603+
};
4604+
4605+
expect(canLeaveChat(report, reportPolicy)).toBe(false);
4606+
});
4607+
4608+
it('should return true for the invited user', async () => {
4609+
const report: Report = {
4610+
...createRandomReport(1),
4611+
chatType: undefined,
4612+
type: CONST.REPORT.TYPE.IOU,
4613+
ownerAccountID: 1,
4614+
managerID: 2,
4615+
};
4616+
4617+
await Onyx.set(ONYXKEYS.SESSION, {email: currentUserEmail, accountID: currentUserAccountID});
4618+
4619+
const reportPolicy: Policy = {
4620+
...createRandomPolicy(1),
4621+
role: CONST.POLICY.ROLE.USER,
4622+
};
4623+
4624+
expect(canLeaveChat(report, reportPolicy)).toBe(true);
4625+
});
4626+
});
45534627
});
45544628

45554629
describe('canJoinChat', () => {

0 commit comments

Comments
 (0)