Skip to content

Commit 3b18d08

Browse files
authored
Merge pull request Expensify#44525 from nkdengineer/fix/44429
fix: Prevent requesting money from domain emails
2 parents 5ab6be6 + b9a6938 commit 3b18d08

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/libs/OptionsListUtils.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ type GetOptionsConfig = {
175175
recentlyUsedPolicyReportFieldOptions?: string[];
176176
transactionViolations?: OnyxCollection<TransactionViolation[]>;
177177
includeInvoiceRooms?: boolean;
178+
includeDomainEmail?: boolean;
178179
};
179180

180181
type GetUserToInviteConfig = {
@@ -1802,6 +1803,7 @@ function getOptions(
18021803
policyReportFieldOptions = [],
18031804
recentlyUsedPolicyReportFieldOptions = [],
18041805
includeInvoiceRooms = false,
1806+
includeDomainEmail = false,
18051807
}: GetOptionsConfig,
18061808
): Options {
18071809
if (includeCategories) {
@@ -1878,6 +1880,8 @@ function getOptions(
18781880
isInFocusMode: false,
18791881
excludeEmptyChats: false,
18801882
includeSelfDM,
1883+
login: option.login,
1884+
includeDomainEmail,
18811885
});
18821886
});
18831887

@@ -1951,7 +1955,9 @@ function getOptions(
19511955
return option;
19521956
});
19531957

1954-
const havingLoginPersonalDetails = includeP2P ? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail) : [];
1958+
const havingLoginPersonalDetails = includeP2P
1959+
? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail && (includeDomainEmail || !Str.isDomainEmail(detail.login)))
1960+
: [];
19551961
let allPersonalDetailsOptions = havingLoginPersonalDetails;
19561962

19571963
if (sortPersonalDetailsByAlphaAsc) {

src/libs/ReportUtils.ts

+9
Original file line numberDiff line numberDiff line change
@@ -5409,6 +5409,8 @@ function shouldReportBeInOptionList({
54095409
excludeEmptyChats,
54105410
doesReportHaveViolations,
54115411
includeSelfDM = false,
5412+
login,
5413+
includeDomainEmail = false,
54125414
}: {
54135415
report: OnyxEntry<Report>;
54145416
currentReportId: string;
@@ -5418,6 +5420,8 @@ function shouldReportBeInOptionList({
54185420
excludeEmptyChats: boolean;
54195421
doesReportHaveViolations: boolean;
54205422
includeSelfDM?: boolean;
5423+
login?: string;
5424+
includeDomainEmail?: boolean;
54215425
}) {
54225426
const isInDefaultMode = !isInFocusMode;
54235427
// Exclude reports that have no data because there wouldn't be anything to show in the option item.
@@ -5521,6 +5525,11 @@ function shouldReportBeInOptionList({
55215525
if (isSelfDM(report)) {
55225526
return includeSelfDM;
55235527
}
5528+
5529+
if (Str.isDomainEmail(login ?? '') && !includeDomainEmail) {
5530+
return false;
5531+
}
5532+
55245533
const parentReportAction = ReportActionsUtils.getParentReportAction(report);
55255534

55265535
// Hide chat threads where the parent message is pending removal

0 commit comments

Comments
 (0)