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
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ EXPENSIFY_ACCOUNT_ID_RECEIPTS=-1
EXPENSIFY_ACCOUNT_ID_REWARDS=-1
EXPENSIFY_ACCOUNT_ID_STUDENT_AMBASSADOR=-1
EXPENSIFY_ACCOUNT_ID_SVFG=-1
EXPENSIFY_ACCOUNT_ID_MANAGER_MCTEST=-1

FB_API_KEY=YOUR_API_KEY
FB_APP_ID=YOUR_APP_ID
Expand Down
5 changes: 0 additions & 5 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ const EMAIL = {
EXPENSIFY_EMAIL_DOMAIN: '@expensify.com',
EXPENSIFY_TEAM_EMAIL_DOMAIN: '@team.expensify.com',
TEAM: 'team@expensify.com',
MANAGER_MCTEST: 'manager_mctest@expensify.com',
QA_GUIDE: 'qa.guide@team.expensify.com',
};

Expand Down Expand Up @@ -912,7 +911,6 @@ const CONST = {
REPORT_FIELDS_FEATURE: 'reportFieldsFeature',
NETSUITE_USA_TAX: 'netsuiteUsaTax',
PER_DIEM: 'newDotPerDiem',
NEWDOT_MANAGER_MCTEST: 'newDotManagerMcTest',
IS_TRAVEL_VERIFIED: 'isTravelVerified',
TRAVEL_INVOICING: 'travelInvoicing',
EXPENSIFY_CARD_EU_UK: 'expensifyCardEuUk',
Expand Down Expand Up @@ -3346,7 +3344,6 @@ const CONST = {
REWARDS: Number(Config?.EXPENSIFY_ACCOUNT_ID_REWARDS ?? 11023767), // rewards@expensify.com
STUDENT_AMBASSADOR: Number(Config?.EXPENSIFY_ACCOUNT_ID_STUDENT_AMBASSADOR ?? 10476956),
SVFG: Number(Config?.EXPENSIFY_ACCOUNT_ID_SVFG ?? 2012843),
MANAGER_MCTEST: Number(Config?.EXPENSIFY_ACCOUNT_ID_MANAGER_MCTEST ?? 18964612),
QA_GUIDE: Number(Config?.EXPENSIFY_ACCOUNT_ID_QA_GUIDE ?? 14365522),
},

Expand Down Expand Up @@ -4826,7 +4823,6 @@ const CONST = {
EMAIL.STUDENT_AMBASSADOR,
EMAIL.SVFG,
EMAIL.TEAM,
EMAIL.MANAGER_MCTEST,
EMAIL.QA_GUIDE,
] as string[],
get EXPENSIFY_ACCOUNT_IDS() {
Expand All @@ -4848,7 +4844,6 @@ const CONST = {
this.ACCOUNT_ID.REWARDS,
this.ACCOUNT_ID.STUDENT_AMBASSADOR,
this.ACCOUNT_ID.SVFG,
this.ACCOUNT_ID.MANAGER_MCTEST,
].filter((id) => id !== -1);
},

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSearchBulkActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable react-hooks/refs */
/* eslint-disable react-hooks/refs -- Refs in this hook are used inside callbacks that capture stable references; the lint rule flags false positives for these patterns */
import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
// eslint-disable-next-line no-restricted-imports
import {InteractionManager} from 'react-native';
Expand Down
37 changes: 1 addition & 36 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import MinHeap from '@libs/MinHeap';
import {getForReportAction} from '@libs/ModifiedExpenseMessage';
import Navigation from '@libs/Navigation/Navigation';
import Parser from '@libs/Parser';
import Permissions from '@libs/Permissions';
import type {OptionData as PersonalDetailOptionData} from '@libs/PersonalDetailOptionsListUtils/types';
import {getDisplayNameOrDefault, getPersonalDetailByEmail, getPersonalDetailsByIDs} from '@libs/PersonalDetailsUtils';
import {addSMSDomainIfPhoneNumber, parsePhoneNumber} from '@libs/PhoneNumber';
Expand Down Expand Up @@ -119,7 +118,6 @@ import type {OptionData} from '@libs/ReportUtils';
import {
canUserPerformWriteAction,
formatReportLastMessageText,
getChatByParticipants,
getChatRoomSubtitle,
getDeletedParentActionMessageForChatReport,
getDeletedTransactionMessage,
Expand Down Expand Up @@ -412,9 +410,7 @@ function shouldShowLastActorDisplayName(
!lastActorDetails ||
reportUtilsIsSelfDM(report) ||
(isDM(report) && lastActorDetails.accountID !== currentUserAccountIDParam) ||
lastActionName === CONST.REPORT.ACTIONS.TYPE.IOU ||
(lastActionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW &&
Object.keys(report?.participants ?? {})?.some((participantID) => participantID === CONST.ACCOUNT_ID.MANAGER_MCTEST.toString()))
lastActionName === CONST.REPORT.ACTIONS.TYPE.IOU
) {
return false;
}
Expand Down Expand Up @@ -2346,17 +2342,6 @@ function prepareReportOptionsForDisplay(
return validOptions;
}

/**
* Returns a list of logins that should be restricted (i.e., hidden or excluded in the UI)
* based on dynamic business logic and feature flags.
* Centralizes restriction logic to avoid scattering conditions across the codebase.
*/
function getRestrictedLogins(config: GetOptionsConfig, options: OptionList, canShowManagerMcTest: boolean): Record<string, boolean> {
return {
[CONST.EMAIL.MANAGER_MCTEST]: !canShowManagerMcTest || !Permissions.isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST, config.betas),
};
}

/**
* Options are reports and personal details. This function filters out the options that are not valid to be displayed.
*/
Expand All @@ -2378,7 +2363,6 @@ function getValidOptions(
shouldSeparateSelfDMChat = false,
shouldSeparateWorkspaceChat = false,
excludeHidden = false,
canShowManagerMcTest = false,
searchString,
searchInputValue,
maxElements,
Expand All @@ -2394,14 +2378,11 @@ function getValidOptions(
...config
}: GetOptionsConfig = {},
): Options {
const restrictedLogins = getRestrictedLogins(config, options, canShowManagerMcTest);

// Gather shared configs:
// Hard exclusions: cannot be selected at all
const loginsToExclude: Record<string, boolean> = {
[CONST.EMAIL.NOTIFICATIONS]: true,
...excludeLogins,
...restrictedLogins,
};

// Soft exclusions: hidden from suggestions but can be manually entered (e.g., Guide/AM)
Expand Down Expand Up @@ -3298,21 +3279,6 @@ function shouldUseBoldText(report: SearchOptionData): boolean {
return report.isUnread === true && notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE && !isHiddenForCurrentUser(notificationPreference);
}

function getManagerMcTestParticipant(currentUserAccountID: number, personalDetails: OnyxEntry<PersonalDetailsList>): Participant | undefined {
// Use O(1) cache lookup when using global personal details, fall back to O(n) search for custom personal details
const managerMcTestPersonalDetails = personalDetails
? Object.values(personalDetails).find((personalDetail) => personalDetail?.login === CONST.EMAIL.MANAGER_MCTEST)
: getPersonalDetailByEmail(CONST.EMAIL.MANAGER_MCTEST);
const managerMcTestReport =
managerMcTestPersonalDetails?.accountID && currentUserAccountID ? getChatByParticipants([managerMcTestPersonalDetails?.accountID, currentUserAccountID]) : undefined;
return managerMcTestPersonalDetails
? {
...getParticipantsOption({...managerMcTestPersonalDetails, keyForList: `${managerMcTestPersonalDetails?.accountID}`}, personalDetails ?? {}),
reportID: managerMcTestReport?.reportID,
}
: undefined;
}

function shallowOptionsListCompare(a: OptionList, b: OptionList): boolean {
if (!a || !b) {
return false;
Expand Down Expand Up @@ -3381,7 +3347,6 @@ export {
getLastActorDisplayName,
getLastActorDisplayNameFromLastVisibleActions,
getLastMessageTextForReport,
getManagerMcTestParticipant,
getParticipantsOption,
getPersonalDetailsForAccountIDs,
getPolicyExpenseReportOption,
Expand Down
1 change: 0 additions & 1 deletion src/libs/OptionsListUtils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ type GetOptionsConfig = {
includeSelectedOptions?: boolean;
recentAttendees?: Option[];
excludeHidden?: boolean;
canShowManagerMcTest?: boolean;
searchString?: string;
searchInputValue?: string;
maxElements?: number;
Expand Down
9 changes: 0 additions & 9 deletions src/libs/QuickActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ const getQuickActionTitle = (action: QuickActionName): TranslationPaths => {
return '' as TranslationPaths;
}
};
const isManagerMcTestQuickActionReport = (report: Report | undefined) => {
return !!report?.participants?.[CONST.ACCOUNT_ID.MANAGER_MCTEST];
};

const isQuickActionAllowed = (
quickAction: QuickAction,
quickActionReport: Report | undefined,
Expand All @@ -127,11 +123,6 @@ const isQuickActionAllowed = (

const iouType = getIOUType(quickAction?.action);
if (iouType) {
// We're disabling QAB for Manager McTest reports to prevent confusion when submitting real data for Manager McTest
const isReportHasManagerMCTest = isManagerMcTestQuickActionReport(quickActionReport);
if (isReportHasManagerMCTest) {
return false;
}
return canCreateRequest(quickActionReport, quickActionPolicy, iouType, isReportArchived, betas, isRestrictedToPreferredPolicy);
}
return true;
Expand Down
48 changes: 1 addition & 47 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7142,22 +7142,6 @@ function buildOptimisticIOUReportAction(params: BuildOptimisticIOUReportActionPa
message: getIOUReportActionMessage(iouReportID, type, amount, comment, currency, paymentType, isSettlingUp, bankAccountID, payAsBusiness),
};

const managerMcTestParticipant = participants.find((participant) => isSelectedManagerMcTest(participant.login));
if (managerMcTestParticipant) {
return {
...iouReportAction,
actorAccountID: managerMcTestParticipant.accountID,
avatar: managerMcTestParticipant.icons?.[0]?.source,
person: [
{
style: 'strong',
text: getDisplayNameForParticipant({...managerMcTestParticipant, formatPhoneNumber: formatPhoneNumberPhoneUtils}),
type: 'TEXT',
},
],
};
}

return iouReportAction;
}

Expand Down Expand Up @@ -7494,7 +7478,6 @@ function buildOptimisticReportPreview(
const created = DateUtils.getDBTime();
const reportActorAccountID = (isInvoiceReport(iouReport) || isExpenseReport(iouReport) ? iouReport?.ownerAccountID : iouReport?.managerID) ?? -1;
const delegateAccountDetails = getPersonalDetailByEmail(delegateEmail);
const isTestTransaction = isTestTransactionReport(iouReport);
const isTestDriveTransaction = !!transaction?.receipt?.isTestDriveReceipt;
const isScanRequest = transaction ? isScanRequestTransactionUtils(transaction) : false;
return {
Expand Down Expand Up @@ -7526,7 +7509,7 @@ function buildOptimisticReportPreview(
childRecentReceiptTransactionIDs: hasReceipt && !isEmptyObject(transaction) && transaction?.transactionID ? {[transaction.transactionID]: created} : undefined,
childOwnerAccountID: iouReport?.ownerAccountID,
childManagerAccountID: iouReport?.managerID,
...((isTestDriveTransaction || isTestTransaction) && !isScanRequest && {childStateNum: 2, childStatusNum: 4}),
...(isTestDriveTransaction && !isScanRequest && {childStateNum: 2, childStatusNum: 4}),
};
}

Expand Down Expand Up @@ -10018,14 +10001,6 @@ function getMoneyRequestOptions(
const policyOwnerAccountID = getPolicy(report?.policyID)?.ownerAccountID;
const isPolicyOwnedByExpensifyAccounts = policyOwnerAccountID ? CONST.EXPENSIFY_ACCOUNT_IDS.includes(policyOwnerAccountID) : false;
if (doParticipantsIncludeExpensifyAccounts && !isPolicyOwnedByExpensifyAccounts && !isPolicyExpenseChat(report) && !isExpenseReport(report)) {
// Allow create expense option for Manager McTest report
if (
canRequestMoney(report, policy, otherParticipants) &&
reportParticipants.some((accountID) => accountID === CONST.ACCOUNT_ID.MANAGER_MCTEST) &&
Permissions.isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST, betas)
) {
return [CONST.IOU.TYPE.SUBMIT];
}
return [];
}

Expand Down Expand Up @@ -10948,11 +10923,8 @@ function shouldDisableThread(reportAction: OnyxInputOrEntry<ReportAction>, isThr
const isWhisperActionLocal = isWhisperAction(reportAction) || isActionableTrackExpense(reportAction);
const isDynamicWorkflowRoutedAction = isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED);
const isActionDisabled = CONST.REPORT.ACTIONS.THREAD_DISABLED.some((action: string) => action === reportAction?.actionName);
const isManagerMcTestOwner = reportAction?.actorAccountID === CONST.ACCOUNT_ID.MANAGER_MCTEST;

return (
isActionDisabled ||
isManagerMcTestOwner ||
isSplitBillAction ||
(isDeletedActionLocal && !reportAction?.childVisibleActionCount) ||
(isReportArchived && !reportAction?.childVisibleActionCount) ||
Expand Down Expand Up @@ -12637,22 +12609,6 @@ function getReportMetadata(reportID: string | undefined) {
return reportID ? allReportMetadataKeyValue[reportID] : undefined;
}

/**
* Helper method to check if participant email is Manager McTest
*/
function isSelectedManagerMcTest(email: string | null | undefined): boolean {
return email === CONST.EMAIL.MANAGER_MCTEST;
}

/**
* Helper method to check if the report is a test transaction report
*/
function isTestTransactionReport(report: OnyxEntry<Report>): boolean {
const managerID = report?.managerID ?? CONST.DEFAULT_NUMBER_ID;
const personalDetails = allPersonalDetails?.[managerID];
return isSelectedManagerMcTest(personalDetails?.login);
}

function isWaitingForSubmissionFromCurrentUser(chatReport: OnyxEntry<Report>, policy: OnyxEntry<Policy>) {
return chatReport?.isOwnPolicyExpenseChat && !policy?.harvesting?.enabled;
}
Expand Down Expand Up @@ -13542,8 +13498,6 @@ export {
getReportMetadata,
buildOptimisticSelfDMReport,
isHiddenForCurrentUser,
isSelectedManagerMcTest,
isTestTransactionReport,
getReportSubtitlePrefix,
computeOptimisticReportName,
getPolicyChangeMessage,
Expand Down
32 changes: 2 additions & 30 deletions src/libs/actions/IOU/MoneyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import {toLocaleDigit} from '@libs/LocaleDigitUtils';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import {roundToTwoDecimalPlaces} from '@libs/NumberUtils';
import {getManagerMcTestParticipant, getParticipantsOption, getReportOption} from '@libs/OptionsListUtils';
import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils';
import {getCustomUnitID} from '@libs/PerDiemRequestUtils';
import {getDistanceRateCustomUnit} from '@libs/PolicyUtils';
import {
generateReportID,
getPolicyExpenseChat,
getReportOrDraftReport,
isInvoiceRoom,
Expand Down Expand Up @@ -135,7 +134,6 @@ type MoneyRequestStepScanParticipantsFlowParams = {
policyRecentlyUsedCurrencies?: string[];
introSelected?: IntroSelected;
files: ReceiptFile[];
isTestTransaction?: boolean;
locationPermissionGranted?: boolean;
shouldGenerateTransactionThreadReport: boolean;
selfDMReport: OnyxEntry<Report>;
Expand Down Expand Up @@ -358,7 +356,6 @@ function handleMoneyRequestStepScanParticipants({
policyRecentlyUsedCurrencies,
introSelected,
files,
isTestTransaction = false,
locationPermissionGranted = false,
selfDMReport,
isSelfTourViewed,
Expand All @@ -376,28 +373,6 @@ function handleMoneyRequestStepScanParticipants({
return;
}

if (isTestTransaction) {
const managerMcTestParticipant = getManagerMcTestParticipant(currentUserAccountID, personalDetails) ?? {};
let reportIDParam = managerMcTestParticipant.reportID;
if (!managerMcTestParticipant.reportID && report?.reportID) {
reportIDParam = generateReportID();
}
setMoneyRequestParticipants(
initialTransaction.transactionID,
[
{
...managerMcTestParticipant,
reportID: reportIDParam,
selected: true,
},
],
true,
).then(() => {
navigateToConfirmationPage(iouType, initialTransaction.transactionID, reportID, backToReport, true, reportIDParam);
});
return;
}

// If the user started this flow from using the + button in the composer inside a report
// the participants can be automatically assigned from the report and the user can skip the participants step and go straight
// to the confirmation step.
Expand Down Expand Up @@ -1087,12 +1062,9 @@ function startDistanceRequest(
}
}

function setMoneyRequestParticipants(transactionID: string, participants: Participant[] = [], isTestTransaction = false) {
// We should change the reportID and isFromGlobalCreate of the test transaction since this flow can start inside an existing report
function setMoneyRequestParticipants(transactionID: string, participants: Participant[] = []) {
return Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {
participants,
isFromGlobalCreate: isTestTransaction ? true : undefined,
reportID: isTestTransaction ? participants?.at(0)?.reportID : undefined,
});
}

Expand Down
Loading
Loading