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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function MovedTransactionAction({action, emptyHTML, childReport, originalReport}

const [toReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${toReportID}`);
const [fromReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${fromReportID}`);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);

const isPendingDelete = fromReport?.pendingFields?.preview === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
// When the transaction is moved from personal space (unreported), fromReportID will be "0" which doesn't exist in allReports
Expand All @@ -46,7 +47,7 @@ function MovedTransactionAction({action, emptyHTML, childReport, originalReport}
return emptyHTML;
}

const message = getMovedTransactionMessage(translate, action);
const message = getMovedTransactionMessage(translate, action, conciergeReportID);

if (hasReasoning(action)) {
return (
Expand Down
5 changes: 2 additions & 3 deletions src/libs/ReportNameUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ function computeReportNameBasedOnReportAction(
reportPolicy: Policy | undefined,
parentReport: Report | undefined,
personalDetailsList: OnyxEntry<PersonalDetailsList>,
// TODO: Make this required when https://github.com/Expensify/App/issues/66411 is done
conciergeReportID?: string,
conciergeReportID: string | undefined,
): string | undefined {
if (!parentReportAction) {
return undefined;
Expand Down Expand Up @@ -533,7 +532,7 @@ function computeReportNameBasedOnReportAction(
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION)) {
return Parser.htmlToText(getMovedTransactionMessage(translate, parentReportAction));
return Parser.htmlToText(getMovedTransactionMessage(translate, parentReportAction, conciergeReportID));
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) {
Expand Down
3 changes: 1 addition & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({

Check warning on line 1048 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
Expand All @@ -1053,7 +1053,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 1056 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -1071,7 +1071,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 1074 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (deprecatedCurrentUserAccountID) {
Expand All @@ -1083,7 +1083,7 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 1086 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
Expand All @@ -1091,7 +1091,7 @@

let allPolicies: OnyxCollection<Policy>;
let policiesArray: Policy[] = [];
Onyx.connect({

Check warning on line 1094 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1101,7 +1101,7 @@
});

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 1104 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_DRAFTS,
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
Expand All @@ -1109,7 +1109,7 @@

let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
Onyx.connect({

Check warning on line 1112 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1145,14 +1145,14 @@
});

let betaConfiguration: OnyxEntry<BetaConfiguration> = {};
Onyx.connect({

Check warning on line 1148 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETA_CONFIGURATION,
callback: (value) => (betaConfiguration = value ?? {}),
});

let deprecatedAllTransactions: OnyxCollection<Transaction> = {};
let deprecatedReportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({

Check warning on line 1155 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1178,7 +1178,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 1181 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -6945,8 +6945,7 @@
return message;
}

// TODO: conciergeReportID will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/66411
function getMovedTransactionMessage(translate: LocalizedTranslate, action: ReportAction, conciergeReportID?: string) {
function getMovedTransactionMessage(translate: LocalizedTranslate, action: ReportAction, conciergeReportID: string | undefined) {
const movedTransactionOriginalMessage = getOriginalMessage(action) ?? {};
const {toReportID, fromReportID} = movedTransactionOriginalMessage as OriginalMessageMovedTransaction;

Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ function getOptionData({
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_OWNERSHIP) {
result.alternateText = Parser.htmlToText(getUpdatedOwnershipMessage(translate, lastAction, policy));
} else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION)) {
result.alternateText = Parser.htmlToText(getMovedTransactionMessage(translate, lastAction));
result.alternateText = Parser.htmlToText(getMovedTransactionMessage(translate, lastAction, conciergeReportID));
} else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.SETTLEMENT_ACCOUNT_LOCKED)) {
result.alternateText = Parser.htmlToText(getSettlementAccountLockedMessage(translate, lastAction));
} else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) {
Expand Down
8 changes: 5 additions & 3 deletions src/libs/actions/IOU/MoneyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ type MoneyRequestStepDistanceNavigationParams = {
amountOwed: OnyxEntry<number>;
userBillingGracePeriodEnds: OnyxCollection<BillingGraceEndPeriod>;
ownerBillingGracePeriodEnd?: OnyxEntry<number>;
conciergeReportID: string | undefined;
};

function createTransaction({
Expand Down Expand Up @@ -289,6 +290,7 @@ function getMoneyRequestParticipantOptions(
report: OnyxEntry<Report>,
policy: OnyxEntry<Policy>,
personalDetails: OnyxEntry<PersonalDetailsList>,
conciergeReportID: string | undefined,
privateIsArchived?: boolean,
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
): Array<Participant | OptionData> {
Expand All @@ -297,8 +299,7 @@ function getMoneyRequestParticipantOptions(
const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID;
return participantAccountID
? getParticipantsOption(participant, personalDetails)
: // TODO: We'll pass the conciergeReportID in the next PR. Refactor issue: https://github.com/Expensify/App/issues/66411
getReportOption(participant, privateIsArchived, policy, personalDetails, undefined, reportAttributesDerived);
: getReportOption(participant, privateIsArchived, policy, personalDetails, conciergeReportID, reportAttributesDerived);
});
}

Expand Down Expand Up @@ -596,6 +597,7 @@ function handleMoneyRequestStepDistanceNavigation({
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
conciergeReportID,
}: MoneyRequestStepDistanceNavigationParams) {
const isManualDistance = manualDistance !== undefined;
const isOdometerDistance = odometerDistance !== undefined;
Expand All @@ -618,7 +620,7 @@ function handleMoneyRequestStepDistanceNavigation({
// to the confirm step.
// If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page.
if (report?.reportID && !isArchivedExpenseReport && iouType !== CONST.IOU.TYPE.CREATE) {
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, report, policy, personalDetails, privateIsArchived, reportAttributesDerived);
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, report, policy, personalDetails, conciergeReportID, privateIsArchived, reportAttributesDerived);

setDistanceRequestData?.(participants);
if (shouldSkipConfirmation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ const ContextMenuActions: ContextMenuAction[] = [
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL) || isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.REROUTE)) {
setClipboardMessage(getChangedApproverActionMessage(translate, reportAction));
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION)) {
setClipboardMessage(getMovedTransactionMessage(translate, reportAction));
setClipboardMessage(getMovedTransactionMessage(translate, reportAction, conciergeReportID));
} else if (isMovedAction(reportAction)) {
setClipboardMessage(getMovedActionMessage(translate, reportAction, originalReport));
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_FRAUD_ALERT)) {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function IOURequestStepDistance({
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);

const isEditing = action === CONST.IOU.ACTION.EDIT;
const isEditingSplit = (iouType === CONST.IOU.TYPE.SPLIT || iouType === CONST.IOU.TYPE.SPLIT_EXPENSE) && isEditing;
Expand Down Expand Up @@ -342,6 +343,7 @@ function IOURequestStepDistance({
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
conciergeReportID,
});
}, [
iouType,
Expand Down Expand Up @@ -379,6 +381,7 @@ function IOURequestStepDistance({
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
conciergeReportID,
]);

const getError = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function IOURequestStepDistanceGPS({
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const isEditing = action === CONST.IOU.ACTION.EDIT;
const isCreatingNewRequest = !isEditing;
// eslint-disable-next-line rulesdir/no-negated-variables
Expand Down Expand Up @@ -132,6 +133,7 @@ function IOURequestStepDistanceGPS({
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
conciergeReportID,
});
};

Expand Down
3 changes: 3 additions & 0 deletions src/pages/iou/request/step/IOURequestStepDistanceManual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function IOURequestStepDistanceManual({
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);

const [splitDraftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`);

Expand Down Expand Up @@ -251,6 +252,7 @@ function IOURequestStepDistanceManual({
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
conciergeReportID,
});
},
[
Expand Down Expand Up @@ -297,6 +299,7 @@ function IOURequestStepDistanceManual({
isSelfTourViewed,
amountOwed,
ownerBillingGracePeriodEnd,
conciergeReportID,
],
);

Expand Down
3 changes: 3 additions & 0 deletions src/pages/iou/request/step/IOURequestStepDistanceMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function IOURequestStepDistanceMap({
const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const isEditing = action === CONST.IOU.ACTION.EDIT;
const isEditingSplit = (iouType === CONST.IOU.TYPE.SPLIT || iouType === CONST.IOU.TYPE.SPLIT_EXPENSE) && isEditing;
const currentTransaction = isEditingSplit && !isEmpty(splitDraftTransaction) ? splitDraftTransaction : transaction;
Expand Down Expand Up @@ -334,6 +335,7 @@ function IOURequestStepDistanceMap({
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
conciergeReportID,
});
}, [
iouType,
Expand Down Expand Up @@ -371,6 +373,7 @@ function IOURequestStepDistanceMap({
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
conciergeReportID,
]);

const getError = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function IOURequestStepDistanceOdometer({
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [selectedTab, selectedTabResult] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.DISTANCE_REQUEST_TYPE}`);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const isLoadingSelectedTab = isLoadingOnyxValue(selectedTabResult);

// isEditing: we're changing an already existing odometer expense; isEditingConfirmation: we navigated here by pressing 'Distance' field from the confirmation step during the creation of a new odometer expense to adjust the input before submitting
Expand Down Expand Up @@ -503,6 +504,7 @@ function IOURequestStepDistanceOdometer({
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
conciergeReportID,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ function useReceiptScan({
const [receiptFiles, setReceiptFiles] = useState<ReceiptFile[]>([]);

const [recentWaypoints] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);

const participants = useMemo(
() => getMoneyRequestParticipantOptions(currentUserPersonalDetails.accountID, report, policy, personalDetails, isArchived, reportAttributesDerived),
[currentUserPersonalDetails.accountID, report, policy, personalDetails, isArchived, reportAttributesDerived],
() => getMoneyRequestParticipantOptions(currentUserPersonalDetails.accountID, report, policy, personalDetails, conciergeReportID, isArchived, reportAttributesDerived),
[currentUserPersonalDetails.accountID, report, policy, personalDetails, conciergeReportID, isArchived, reportAttributesDerived],
);

const participantsPolicyTags = useParticipantsPolicyTags(participants);
Expand Down
96 changes: 94 additions & 2 deletions tests/actions/IOU/MoneyRequestTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,14 @@ describe('MoneyRequest', () => {
},
});
baseParams.recentWaypoints = (await getOnyxValue(ONYXKEYS.NVP_RECENT_WAYPOINTS)) ?? [];
baseParams.participants = getMoneyRequestParticipantOptions(baseParams.currentUserAccountID, baseParams.report, baseParams.policy, baseParams.personalDetails, undefined, {});
baseParams.participants = getMoneyRequestParticipantOptions(
baseParams.currentUserAccountID,
baseParams.report,
baseParams.policy,
baseParams.personalDetails,
undefined,
undefined,
);
await getOnyxData({
key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}`,
waitForCollectionCallback: true,
Expand Down Expand Up @@ -577,7 +584,7 @@ describe('MoneyRequest', () => {
...fakeReport,
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
};
baseParams.participants = getMoneyRequestParticipantOptions(baseParams.currentUserAccountID, report, baseParams.policy, baseParams.personalDetails, undefined, {});
baseParams.participants = getMoneyRequestParticipantOptions(baseParams.currentUserAccountID, report, baseParams.policy, baseParams.personalDetails, undefined, undefined);

await getOnyxData({
key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}`,
Expand Down Expand Up @@ -949,6 +956,7 @@ describe('MoneyRequest', () => {
amountOwed: 0,
draftTransactionIDs: undefined,
userBillingGracePeriodEnds: undefined,
conciergeReportID: undefined,
};
const splitShares: SplitShares = {
[firstSplitParticipantID]: {
Expand Down Expand Up @@ -1371,6 +1379,90 @@ describe('MoneyRequest', () => {

expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.CREATE, baseParams.transactionID, baseParams.reportID));
});

it('should pass conciergeReportID through to getMoneyRequestParticipantOptions when report exists', async () => {
const conciergeReportID = 'concierge789';
handleMoneyRequestStepDistanceNavigation({
...baseParams,
iouType: CONST.IOU.TYPE.SUBMIT,
shouldSkipConfirmation: false,
isArchivedExpenseReport: false,
draftTransactionIDs: [baseParams.transactionID],
conciergeReportID,
});

// When report exists and iouType is not CREATE, the function calls getMoneyRequestParticipantOptions
// with conciergeReportID, sets distance request data, and then navigates to confirmation page
await waitForBatchedUpdates();
expect(baseParams.setDistanceRequestData).toHaveBeenCalled();
});

it('should work correctly when conciergeReportID is undefined', async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify what is work correctly in this case.

handleMoneyRequestStepDistanceNavigation({
...baseParams,
iouType: CONST.IOU.TYPE.SUBMIT,
shouldSkipConfirmation: false,
isArchivedExpenseReport: false,
draftTransactionIDs: [baseParams.transactionID],
conciergeReportID: undefined,
});

await waitForBatchedUpdates();
expect(baseParams.setDistanceRequestData).toHaveBeenCalled();
});
});

describe('getMoneyRequestParticipantOptions', () => {
const fakeReport = createRandomReport(1, CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT);
const fakePolicy = createRandomPolicy(1, CONST.POLICY.TYPE.TEAM);

beforeEach(async () => {
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${fakeReport.reportID}`, {
...fakeReport,
participants: {
[TEST_USER_ACCOUNT_ID]: {
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS,
role: CONST.REPORT.ROLE.MEMBER,
},
},
});
});

afterEach(async () => {
await Onyx.clear();
});

it('should return participants when conciergeReportID is undefined', () => {
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, fakeReport, fakePolicy, {}, undefined);
expect(Array.isArray(participants)).toBe(true);
});

it('should return participants when conciergeReportID is provided', () => {
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, fakeReport, fakePolicy, {}, 'concierge123');
expect(Array.isArray(participants)).toBe(true);
});

it('should pass conciergeReportID through to getReportOption for policy expense chat participants', () => {
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, fakeReport, fakePolicy, {}, 'concierge456');
// For policy expense chat, participants have accountID 0 and go through getReportOption
// which uses conciergeReportID for identifying concierge chat
expect(Array.isArray(participants)).toBe(true);
expect(participants.length).toBeGreaterThan(0);
});

it('should return participants with privateIsArchived passed through', () => {
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, fakeReport, fakePolicy, {}, undefined, true);
expect(Array.isArray(participants)).toBe(true);
});

it('should return participants for report with no chat participants (DM-like)', () => {
const dmReport = {
...createRandomReport(2, undefined),
participants: {},
};
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, dmReport, fakePolicy, {}, undefined);
expect(Array.isArray(participants)).toBe(true);
});
});

describe('shouldUseDefaultExpensePolicy', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/OptionsListUtilsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4088,7 +4088,7 @@ describe('OptionsListUtils', () => {

currentUserLogin: CURRENT_USER_EMAIL,
});
expect(lastMessage).toBe(Parser.htmlToText(getMovedTransactionMessage(translateLocal, movedTransactionAction)));
expect(lastMessage).toBe(Parser.htmlToText(getMovedTransactionMessage(translateLocal, movedTransactionAction, undefined)));
});
describe('SUBMITTED action', () => {
it('should return automatic submitted message if submitted via harvesting', async () => {
Expand Down
Loading
Loading