Skip to content
Merged
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
18 changes: 3 additions & 15 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1074,14 +1074,6 @@ const FALLBACK_TITLE_FIELD: PolicyReportField = {
isTax: false,
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
},
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({
key: ONYXKEYS.SESSION,
Expand Down Expand Up @@ -12589,8 +12581,8 @@ type PrepareOnboardingOnyxDataParams = {
isSelfTourViewed?: boolean;
// TODO: should be required field. Refactor issue: https://github.com/Expensify/App/issues/66412
currentUserEmail?: string;
/** The concierge chat report, looked up by conciergeReportID. Falls back to getChatByParticipants using the deprecated module-level Onyx data while the refactor is in progress. */
conciergeChat?: OnyxEntry<Report>;
/** The concierge chat report, looked up by conciergeReportID */
conciergeChat: OnyxEntry<Report>;
/** The admins chat report, looked up by adminsChatReportID. Falls back to the deprecated module-level Onyx data while the refactor is in progress. */
adminsChatReport?: OnyxEntry<Report>;
/** The self-DM report, looked up by ONYXKEYS.SELF_DM_REPORT_ID. Falls back to the deprecated module-level Onyx data while the refactor is in progress. */
Expand All @@ -12614,7 +12606,7 @@ function prepareOnboardingOnyxData({
onboardingPurposeSelected,
isSelfTourViewed,
currentUserEmail,
conciergeChat: conciergeChatParam,
conciergeChat,
adminsChatReport: adminsChatReportParam,
selfDMReport: selfDMReportParam,
currentUserAccountID,
Expand All @@ -12634,10 +12626,6 @@ function prepareOnboardingOnyxData({
// Server picks the inboxAdminsBespoke variant at response time, so optimistic writes here would be stale.
const shouldDeferOptimisticTasks = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM;
const adminsChatReport = adminsChatReportParam ?? deprecatedAllReports?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`];
const conciergeChat =
conciergeChatParam ??
getChatByParticipants([CONST.ACCOUNT_ID.CONCIERGE, deprecatedCurrentUserAccountID ?? CONST.DEFAULT_NUMBER_ID], deprecatedAllReports, false) ??
(conciergeReportIDOnyxConnect ? {reportID: conciergeReportIDOnyxConnect} : undefined);
const targetChatReport = shouldPostTasksInAdminsRoom
? (adminsChatReport ?? {reportID: adminsChatReportID, policyID: onboardingPolicyID, chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS})
: conciergeChat;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ type OpenReportActionParams = {
/** Beta features list */
betas: OnyxEntry<Beta[]>;

/** This will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/66411 */
conciergeChat?: OnyxEntry<Report>;
/** The Concierge chat report used to build the guided setup onboarding data */
conciergeChat: OnyxEntry<Report>;
};

type PregeneratedResponseParams = {
Expand Down
6 changes: 6 additions & 0 deletions tests/actions/IOUTest/DeleteMoneyRequestTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => {
}));
// When Opening a thread report with the given details
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: TEST_INTRO_SELECTED,
Expand Down Expand Up @@ -651,6 +652,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => {

// When Opening a thread report with the given details
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: TEST_INTRO_SELECTED,
Expand Down Expand Up @@ -786,6 +788,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => {
accountID: participantAccountIDs.at(index),
}));
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: TEST_INTRO_SELECTED,
Expand Down Expand Up @@ -933,6 +936,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => {
accountID: participantAccountIDs.at(index),
}));
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: TEST_INTRO_SELECTED,
Expand Down Expand Up @@ -1261,6 +1265,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => {
accountID: participantAccountIDs.at(index),
}));
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: TEST_INTRO_SELECTED,
Expand Down Expand Up @@ -1448,6 +1453,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => {
accountID: participantAccountIDs.at(index),
}));
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: TEST_INTRO_SELECTED,
Expand Down
2 changes: 2 additions & 0 deletions tests/actions/IOUTest/DuplicateTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ describe('actions/Duplicate', () => {
accountID: participantAccountIDs.at(index),
}));
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: transactionThreadReport1.reportID,
introSelected: undefined,
Expand All @@ -562,6 +563,7 @@ describe('actions/Duplicate', () => {
currentUserAccountID: RORY_ACCOUNT_ID,
});
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: transactionThreadReport2.reportID,
introSelected: undefined,
Expand Down
2 changes: 2 additions & 0 deletions tests/actions/IOUTest/TrackExpenseTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,7 @@ describe('actions/IOU/TrackExpense', () => {
accountID: participantAccountIDs.at(index),
}));
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: TEST_INTRO_SELECTED,
Expand Down Expand Up @@ -2561,6 +2562,7 @@ describe('actions/IOU/TrackExpense', () => {
accountID: participantAccountIDs.at(index),
}));
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: TEST_INTRO_SELECTED,
Expand Down
2 changes: 2 additions & 0 deletions tests/actions/MergeTransactionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ describe('mergeTransactionRequest', () => {
accountID: participantAccountIDs.at(index),
}));
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: undefined,
Expand Down Expand Up @@ -1375,6 +1376,7 @@ describe('mergeTransactionRequest', () => {
accountID: participantAccountIDs.at(index),
}));
openReport({
conciergeChat: undefined,
hasReportActions: true,
reportID: thread.reportID,
introSelected: undefined,
Expand Down
14 changes: 6 additions & 8 deletions tests/actions/PolicyTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,9 +1512,8 @@ describe('actions/Policy', () => {

it('should mark VIEW_TOUR task as completed in guidedSetupData when isSelfTourViewed is true', async () => {
await Onyx.set(ONYXKEYS.SESSION, {email: ESH_EMAIL, accountID: ESH_ACCOUNT_ID});
// EMPLOYER posts onboarding tasks to the Concierge chat (not #admins). Set a concierge
// report ID so prepareOnboardingOnyxData can resolve a target chat and does not early-return.
await Onyx.set(ONYXKEYS.CONCIERGE_REPORT_ID, 'concierge-report-1');
// EMPLOYER posts onboarding tasks to the Concierge chat (not #admins), so the concierge
// chat is passed below and prepareOnboardingOnyxData does not early-return.
await waitForBatchedUpdates();

const apiWriteSpy = jest.spyOn(APIModule, 'write').mockImplementation(() => Promise.resolve());
Expand All @@ -1526,7 +1525,7 @@ describe('actions/Policy', () => {
// EMPLOYER is used because it has a VIEW_TOUR task (testDriveEmployeeTask); MANAGE_TEAM now uses
// the bespoke followups path (no tasks) so it no longer exercises this code path.
Policy.createWorkspace({
conciergeChat: undefined,
conciergeChat: {reportID: 'concierge-report-1', type: CONST.REPORT.TYPE.CHAT},
policyOwnerEmail: ESH_EMAIL,
makeMeAdmin: true,
policyName: WORKSPACE_NAME,
Expand Down Expand Up @@ -1562,9 +1561,8 @@ describe('actions/Policy', () => {

it('should not mark VIEW_TOUR task as completed in guidedSetupData when isSelfTourViewed is false', async () => {
await Onyx.set(ONYXKEYS.SESSION, {email: ESH_EMAIL, accountID: ESH_ACCOUNT_ID});
// EMPLOYER posts onboarding tasks to the Concierge chat (not #admins). Set a concierge
// report ID so prepareOnboardingOnyxData can resolve a target chat and does not early-return.
await Onyx.set(ONYXKEYS.CONCIERGE_REPORT_ID, 'concierge-report-1');
// EMPLOYER posts onboarding tasks to the Concierge chat (not #admins), so the concierge
// chat is passed below and prepareOnboardingOnyxData does not early-return.
await waitForBatchedUpdates();

const apiWriteSpy = jest.spyOn(APIModule, 'write').mockImplementation(() => Promise.resolve());
Expand All @@ -1576,7 +1574,7 @@ describe('actions/Policy', () => {
// EMPLOYER is used because it has a VIEW_TOUR task (testDriveEmployeeTask); MANAGE_TEAM now uses
// the bespoke followups path (no tasks) so it no longer exercises this code path.
Policy.createWorkspace({
conciergeChat: undefined,
conciergeChat: {reportID: 'concierge-report-1', type: CONST.REPORT.TYPE.CHAT},
policyOwnerEmail: ESH_EMAIL,
makeMeAdmin: true,
policyName: WORKSPACE_NAME,
Expand Down
Loading
Loading