Skip to content

Commit

Permalink
Merge pull request Expensify#44525 from nkdengineer/fix/44429
Browse files Browse the repository at this point in the history
fix: Prevent requesting money from domain emails
  • Loading branch information
techievivek authored Jul 3, 2024
2 parents 5ab6be6 + b9a6938 commit 3b18d08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ type GetOptionsConfig = {
recentlyUsedPolicyReportFieldOptions?: string[];
transactionViolations?: OnyxCollection<TransactionViolation[]>;
includeInvoiceRooms?: boolean;
includeDomainEmail?: boolean;
};

type GetUserToInviteConfig = {
Expand Down Expand Up @@ -1802,6 +1803,7 @@ function getOptions(
policyReportFieldOptions = [],
recentlyUsedPolicyReportFieldOptions = [],
includeInvoiceRooms = false,
includeDomainEmail = false,
}: GetOptionsConfig,
): Options {
if (includeCategories) {
Expand Down Expand Up @@ -1878,6 +1880,8 @@ function getOptions(
isInFocusMode: false,
excludeEmptyChats: false,
includeSelfDM,
login: option.login,
includeDomainEmail,
});
});

Expand Down Expand Up @@ -1951,7 +1955,9 @@ function getOptions(
return option;
});

const havingLoginPersonalDetails = includeP2P ? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail) : [];
const havingLoginPersonalDetails = includeP2P
? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail && (includeDomainEmail || !Str.isDomainEmail(detail.login)))
: [];
let allPersonalDetailsOptions = havingLoginPersonalDetails;

if (sortPersonalDetailsByAlphaAsc) {
Expand Down
9 changes: 9 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5409,6 +5409,8 @@ function shouldReportBeInOptionList({
excludeEmptyChats,
doesReportHaveViolations,
includeSelfDM = false,
login,
includeDomainEmail = false,
}: {
report: OnyxEntry<Report>;
currentReportId: string;
Expand All @@ -5418,6 +5420,8 @@ function shouldReportBeInOptionList({
excludeEmptyChats: boolean;
doesReportHaveViolations: boolean;
includeSelfDM?: boolean;
login?: string;
includeDomainEmail?: boolean;
}) {
const isInDefaultMode = !isInFocusMode;
// Exclude reports that have no data because there wouldn't be anything to show in the option item.
Expand Down Expand Up @@ -5521,6 +5525,11 @@ function shouldReportBeInOptionList({
if (isSelfDM(report)) {
return includeSelfDM;
}

if (Str.isDomainEmail(login ?? '') && !includeDomainEmail) {
return false;
}

const parentReportAction = ReportActionsUtils.getParentReportAction(report);

// Hide chat threads where the parent message is pending removal
Expand Down

0 comments on commit 3b18d08

Please sign in to comment.