Skip to content

Commit 5e47899

Browse files
justinpersaudOSBotify
authored andcommitted
Merge pull request #86253 from Expensify/andrew-revert-77636
Revert "Merge pull request #77636 from lorretheboy/fix-part-01/73656" (cherry picked from commit f240cdb) (cherry-picked to staging by AndrewGable)
1 parent 1097dd5 commit 5e47899

13 files changed

Lines changed: 55 additions & 202 deletions

File tree

src/components/PromotedActionsBar.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {joinRoom, navigateToAndOpenReport, navigateToAndOpenReportWithAccountIDs
1313
import {callFunctionIfActionIsAllowed} from '@userActions/Session';
1414
import CONST from '@src/CONST';
1515
import ROUTES from '@src/ROUTES';
16-
import type {PersonalDetailsList} from '@src/types/onyx';
1716
import type Beta from '@src/types/onyx/Beta';
1817
import type OnyxReport from '@src/types/onyx/Report';
1918
import Button from './Button';
@@ -33,7 +32,6 @@ type PromotedActionsType = Record<BasePromotedActions, (report: OnyxReport) => P
3332
accountID?: number;
3433
login?: string;
3534
currentUserAccountID: number;
36-
personalDetails: OnyxEntry<PersonalDetailsList>;
3735
introSelected: OnyxEntry<IntroSelected>;
3836
isSelfTourViewed: boolean | undefined;
3937
betas: OnyxEntry<Beta[]>;
@@ -68,7 +66,7 @@ const PromotedActions = {
6866
joinRoom(report, currentUserAccountID);
6967
}),
7068
}),
71-
message: ({reportID, accountID, login, currentUserAccountID, personalDetails, introSelected, isSelfTourViewed, betas}) => ({
69+
message: ({reportID, accountID, login, currentUserAccountID, introSelected, isSelfTourViewed, betas}) => ({
7270
key: CONST.PROMOTED_ACTIONS.MESSAGE,
7371
icon: 'CommentBubbles',
7472
translationKey: 'common.message',
@@ -80,7 +78,7 @@ const PromotedActions = {
8078

8179
// The accountID might be optimistic, so we should use the login if we have it
8280
if (login) {
83-
navigateToAndOpenReport([login], personalDetails, currentUserAccountID, introSelected, isSelfTourViewed, betas, false);
81+
navigateToAndOpenReport([login], currentUserAccountID, introSelected, isSelfTourViewed, betas, false);
8482
return;
8583
}
8684
if (accountID) {

src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo
7373
const {inputQuery: originalInputQuery} = queryJSON;
7474
const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector});
7575
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
76-
const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
7776
const [betas] = useOnyx(ONYXKEYS.BETAS);
7877
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
7978
const queryText = buildUserReadableQueryString({
@@ -250,10 +249,10 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo
250249
} else if (item?.reportID) {
251250
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(item?.reportID));
252251
} else if ('login' in item) {
253-
navigateToAndOpenReport(item.login ? [item.login] : [], allPersonalDetails, currentUserAccountID, introSelected, isSelfTourViewed, betas, false);
252+
navigateToAndOpenReport(item.login ? [item.login] : [], currentUserAccountID, introSelected, isSelfTourViewed, betas, false);
254253
}
255254
},
256-
[textInputValue, onSearchQueryChange, autocompleteSubstitutions, submitSearch, allPersonalDetails, currentUserAccountID, introSelected, isSelfTourViewed, betas],
255+
[autocompleteSubstitutions, onSearchQueryChange, submitSearch, textInputValue, currentUserAccountID, introSelected, isSelfTourViewed, betas],
257256
);
258257

259258
const searchQueryItem = useMemo(

src/components/Search/SearchRouter/SearchRouter.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
7575
const {shouldUseNarrowLayout} = useResponsiveLayout();
7676
const listRef = useRef<SelectionListWithSectionsHandle>(null);
7777
const expensifyIcons = useMemoizedLazyExpensifyIcons(['MagnifyingGlass']);
78-
const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
7978

8079
// The actual input text that the user sees
8180
const [textInputValue, , setTextInputValue] = useDebouncedState('', 500);
@@ -294,7 +293,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
294293
if (item?.reportID) {
295294
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(item.reportID));
296295
} else if ('login' in item) {
297-
navigateToAndOpenReport(item.login ? [item.login] : [], allPersonalDetails, currentUserAccountID, introSelected, isSelfTourViewed, betas, false);
296+
navigateToAndOpenReport(item.login ? [item.login] : [], currentUserAccountID, introSelected, isSelfTourViewed, betas, false);
298297
}
299298
});
300299
onRouterClose();

src/libs/actions/Report/index.ts

Lines changed: 18 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,8 @@ type OpenReportActionParams = {
279279
/** The ID used to fetch a specific range of report actions related to the current reportActionID when opening a chat */
280280
reportActionID?: string;
281281

282-
/** The list of participants */
283-
participants?: ParticipantInfo[];
284-
285-
/** The personal details of the participants */
286-
personalDetails?: OnyxEntry<PersonalDetailsList>;
282+
/** The list of users that are included in a new chat, not including the user creating it */
283+
participantLoginList?: string[];
287284

288285
/** The optimistic report object created when making a new chat, saved as optimistic data */
289286
newReportObject?: OptimisticChatReport;
@@ -294,6 +291,9 @@ type OpenReportActionParams = {
294291
/** Whether or not this report is being opened from a deep link */
295292
isFromDeepLink?: boolean;
296293

294+
/** The list of accountIDs that are included in a new chat, not including the user creating it */
295+
participantAccountIDList?: number[];
296+
297297
/** Whether this is a new thread being created */
298298
isNewThread?: boolean;
299299

@@ -1188,11 +1188,6 @@ function clearAvatarErrors(reportID: string) {
11881188
});
11891189
}
11901190

1191-
type ParticipantInfo = {
1192-
login: string;
1193-
accountID?: number;
1194-
};
1195-
11961191
type GuidedSetupOptimisticOnyxUpdate = OnyxUpdate<
11971192
typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS | typeof ONYXKEYS.NVP_INTRO_SELECTED | typeof ONYXKEYS.NVP_ONBOARDING | typeof ONYXKEYS.COLLECTION.POLICY
11981193
>;
@@ -1217,13 +1212,6 @@ type GuidedSetupDataForOpenReport = {
12171212
guidedSetupData: string;
12181213
};
12191214

1220-
function buildParticipantInfoFromLogins(logins: string[], accountIDs?: number[]): ParticipantInfo[] {
1221-
return logins.map((login, index) => ({
1222-
login,
1223-
accountID: accountIDs?.[index],
1224-
}));
1225-
}
1226-
12271215
/**
12281216
* Prepares guided setup data for an OpenReport request when onboarding is not yet completed.
12291217
* Returns the onyx data arrays and guidedSetupData string to include in the API parameters,
@@ -1302,11 +1290,11 @@ function openReport(params: OpenReportActionParams) {
13021290
reportID,
13031291
introSelected,
13041292
reportActionID,
1305-
participants = [],
1293+
participantLoginList = [],
13061294
newReportObject,
13071295
parentReportActionID,
13081296
isFromDeepLink = false,
1309-
personalDetails,
1297+
participantAccountIDList = [],
13101298
isNewThread = false,
13111299
transaction,
13121300
transactionViolations,
@@ -1322,9 +1310,6 @@ function openReport(params: OpenReportActionParams) {
13221310
return;
13231311
}
13241312

1325-
const participantLoginList = participants.map((p) => p.login);
1326-
const participantAccountIDList = participants.map((p) => p.accountID).filter((id): id is number => id !== undefined);
1327-
13281313
const optimisticReport = reportActionsExist(reportID)
13291314
? {}
13301315
: {
@@ -1576,7 +1561,7 @@ function openReport(params: OpenReportActionParams) {
15761561

15771562
let emailCreatingAction: string = CONST.REPORT.OWNER_EMAIL_FAKE;
15781563
if (newReportObject.ownerAccountID && newReportObject.ownerAccountID !== CONST.REPORT.OWNER_ACCOUNT_ID_FAKE) {
1579-
emailCreatingAction = personalDetails?.[newReportObject.ownerAccountID]?.login ?? '';
1564+
emailCreatingAction = allPersonalDetails?.[newReportObject.ownerAccountID]?.login ?? '';
15801565
}
15811566
const optimisticCreatedAction = buildOptimisticCreatedReportAction(emailCreatingAction);
15821567
optimisticData.push(
@@ -1614,7 +1599,7 @@ function openReport(params: OpenReportActionParams) {
16141599
const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins(participantLoginList);
16151600
for (const [index, login] of participantLoginList.entries()) {
16161601
const accountID = participantAccountIDs.at(index) ?? -1;
1617-
const isOptimisticAccount = !personalDetails?.[accountID];
1602+
const isOptimisticAccount = !allPersonalDetails?.[accountID];
16181603

16191604
if (!isOptimisticAccount) {
16201605
continue;
@@ -1981,8 +1966,7 @@ function createTransactionThreadReport(
19811966
openReport({
19821967
reportID: optimisticTransactionThreadReportID,
19831968
introSelected,
1984-
participants: currentUserLogin ? [{login: currentUserLogin, accountID: currentUserAccountID}] : [],
1985-
personalDetails: allPersonalDetails,
1969+
participantLoginList: currentUserLogin ? [currentUserLogin] : [],
19861970
newReportObject: optimisticTransactionThread,
19871971
parentReportActionID: iouReportAction?.reportActionID,
19881972
transaction,
@@ -2031,7 +2015,6 @@ function navigateToReport(reportID: string | undefined, shouldDismissModal = tru
20312015
*/
20322016
function navigateToAndOpenReport(
20332017
userLogins: string[],
2034-
personalDetails: OnyxEntry<PersonalDetailsList>,
20352018
currentUserAccountID: number,
20362019
introSelected: OnyxEntry<IntroSelected>,
20372020
isSelfTourViewed: boolean | undefined,
@@ -2047,10 +2030,8 @@ function navigateToAndOpenReport(
20472030
participantList: [...participantAccountIDs, currentUserAccountID],
20482031
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
20492032
});
2050-
2051-
const participants = buildParticipantInfoFromLogins(userLogins, participantAccountIDs);
20522033
// We want to pass newChat here because if anything is passed in that param (even an existing chat), we will try to create a chat on the server
2053-
openReport({reportID: newChat?.reportID, introSelected, reportActionID: '', participants, personalDetails, newReportObject: newChat, isSelfTourViewed, betas});
2034+
openReport({reportID: newChat?.reportID, introSelected, reportActionID: '', participantLoginList: userLogins, newReportObject: newChat, isSelfTourViewed, betas});
20542035
}
20552036
const report = isEmptyObject(chat) ? newChat : chat;
20562037

@@ -2082,43 +2063,20 @@ function navigateToAndCreateGroupChat(
20822063
*
20832064
* @param participantAccountIDs of user logins to start a chat report with.
20842065
*/
2085-
function navigateToAndOpenReportWithAccountIDs(
2086-
participantAccountIDs: number[],
2087-
currentUserAccountID: number,
2088-
introSelected: OnyxEntry<IntroSelected>,
2089-
betas: OnyxEntry<Beta[]>,
2090-
personalDetails?: OnyxEntry<PersonalDetailsList>,
2091-
) {
2066+
function navigateToAndOpenReportWithAccountIDs(participantAccountIDs: number[], currentUserAccountID: number, introSelected: OnyxEntry<IntroSelected>, betas: OnyxEntry<Beta[]>) {
20922067
let newChat: OptimisticChatReport | undefined;
20932068
const chat = getChatByParticipants([...participantAccountIDs, currentUserAccountID]);
20942069
if (!chat) {
20952070
newChat = buildOptimisticChatReport({
20962071
participantList: [...participantAccountIDs, currentUserAccountID],
20972072
});
2098-
2099-
const detailsToUse = personalDetails ?? allPersonalDetails;
2100-
2101-
const participants = participantAccountIDs
2102-
.map((accountID): ParticipantInfo | null => {
2103-
const personalDetail = detailsToUse?.[accountID];
2104-
if (!personalDetail?.login) {
2105-
return null;
2106-
}
2107-
return {
2108-
login: personalDetail.login,
2109-
accountID,
2110-
};
2111-
})
2112-
.filter((p): p is ParticipantInfo => p !== null);
2113-
21142073
// We want to pass newChat here because if anything is passed in that param (even an existing chat), we will try to create a chat on the server
21152074
openReport({
21162075
reportID: newChat?.reportID,
21172076
introSelected,
21182077
newReportObject: newChat,
21192078
parentReportActionID: '0',
2120-
participants,
2121-
personalDetails: detailsToUse,
2079+
participantAccountIDList: participantAccountIDs,
21222080
betas,
21232081
});
21242082
}
@@ -2143,9 +2101,8 @@ function navigateToAndOpenChildReport(
21432101
currentUserAccountID: number,
21442102
introSelected: OnyxEntry<IntroSelected>,
21452103
betas: OnyxEntry<Beta[]>,
2146-
personalDetails?: OnyxEntry<PersonalDetailsList>,
21472104
) {
2148-
const report = childReport ?? createChildReport(childReport, parentReportAction, parentReport, currentUserAccountID, introSelected, betas, personalDetails);
2105+
const report = childReport ?? createChildReport(childReport, parentReportAction, parentReport, currentUserAccountID, introSelected, betas);
21492106

21502107
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID, undefined, undefined, Navigation.getActiveRoute()));
21512108
}
@@ -2162,7 +2119,6 @@ function createChildReport(
21622119
currentUserAccountID: number,
21632120
introSelected: OnyxEntry<IntroSelected>,
21642121
betas: OnyxEntry<Beta[]>,
2165-
personalDetails?: OnyxEntry<PersonalDetailsList>,
21662122
): Report {
21672123
const participantAccountIDs = [...new Set([currentUserAccountID, Number(parentReportAction.actorAccountID)])];
21682124
// Threads from DMs and selfDMs don't have a chatType. All other threads inherit the chatType from their parent
@@ -2182,17 +2138,11 @@ function createChildReport(
21822138

21832139
const childReportID = childReport?.reportID ?? parentReportAction.childReportID;
21842140
if (!childReportID) {
2185-
const participantAccountIDsForDetails = Object.keys(newChat.participants ?? {}).map(Number);
2186-
const participantLogins = PersonalDetailsUtils.getLoginsByAccountIDs(participantAccountIDsForDetails);
2187-
2188-
const detailsToUse = personalDetails ?? allPersonalDetails;
2189-
2190-
const participants = buildParticipantInfoFromLogins(participantLogins, participantAccountIDsForDetails);
2141+
const participantLogins = PersonalDetailsUtils.getLoginsByAccountIDs(Object.keys(newChat.participants ?? {}).map(Number));
21912142
openReport({
21922143
reportID: newChat.reportID,
21932144
introSelected,
2194-
participants,
2195-
personalDetails: detailsToUse,
2145+
participantLoginList: participantLogins,
21962146
newReportObject: newChat,
21972147
parentReportActionID: parentReportAction.reportActionID,
21982148
isNewThread: true,
@@ -3088,11 +3038,10 @@ function toggleSubscribeToChildReport(
30883038
});
30893039

30903040
const participantLogins = PersonalDetailsUtils.getLoginsByAccountIDs(participantAccountIDs);
3091-
const participants = buildParticipantInfoFromLogins(participantLogins, participantAccountIDs);
30923041
openReport({
30933042
reportID: newChat.reportID,
30943043
introSelected,
3095-
participants,
3044+
participantLoginList: participantLogins,
30963045
newReportObject: newChat,
30973046
parentReportActionID: parentReportAction.reportActionID,
30983047
isSelfTourViewed,
@@ -3512,7 +3461,7 @@ function navigateToConciergeChat(
35123461
if (!checkIfCurrentPageActive()) {
35133462
return;
35143463
}
3515-
navigateToAndOpenReport([CONST.EMAIL.CONCIERGE], allPersonalDetails, currentUserAccountID, introSelected, isSelfTourViewed, undefined, shouldDismissModal);
3464+
navigateToAndOpenReport([CONST.EMAIL.CONCIERGE], currentUserAccountID, introSelected, isSelfTourViewed, undefined, shouldDismissModal);
35163465
});
35173466
} else if (shouldDismissModal) {
35183467
Navigation.dismissModalWithReport({reportID: conciergeReportID, reportActionID});
@@ -7412,5 +7361,3 @@ export {
74127361
prepareOnyxDataForCleanUpOptimisticParticipants,
74137362
getGuidedSetupDataForOpenReport,
74147363
};
7415-
7416-
export type {ParticipantInfo};

src/pages/NewChatConfirmPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ function NewChatConfirmPage() {
4141
const {translate, localeCompare, formatPhoneNumber} = useLocalize();
4242
const styles = useThemeStyles();
4343
const personalData = useCurrentUserPersonalDetails();
44-
4544
const [newGroupDraft, newGroupDraftMetaData] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT);
4645
const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
4746
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);

src/pages/NewChatPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ function NewChatPage({ref}: NewChatPageProps) {
362362
Navigation.dismissModalWithReport({reportID: option.reportID});
363363
return;
364364
}
365+
365366
if (selectedOptions.length && option) {
366367
// Prevent excluded emails from being added to groups
367368
if (option?.login && excludedGroupEmails.has(option.login)) {
@@ -392,7 +393,7 @@ function NewChatPage({ref}: NewChatPageProps) {
392393
return;
393394
}
394395
KeyboardUtils.dismiss().then(() => {
395-
singleExecution(() => navigateToAndOpenReport([login], allPersonalDetails, currentUserAccountID, introSelected, isSelfTourViewed, betas))();
396+
singleExecution(() => navigateToAndOpenReport([login], currentUserAccountID, introSelected, isSelfTourViewed, betas))();
396397
});
397398
};
398399

src/pages/ProfilePage.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ function ProfilePage({route}: ProfilePageProps) {
8181
const guideCalendarLink = account?.guideDetails?.calendarLink ?? '';
8282
const expensifyIcons = useMemoizedLazyExpensifyIcons(['Bug', 'Pencil', 'Phone']);
8383
const accountID = Number(route.params?.accountID ?? CONST.DEFAULT_NUMBER_ID);
84-
const loginParams = route.params?.login;
85-
8684
const isCurrentUser = currentUserAccountID === accountID;
8785
const reportID = isCurrentUser ? findSelfDMReportID() : getChatByParticipants(currentUserAccountID ? [accountID, currentUserAccountID] : [], reports)?.reportID;
8886
const reportKey = isAnonymousUserSession() || !reportID ? (`${ONYXKEYS.COLLECTION.REPORT}0` as const) : (`${ONYXKEYS.COLLECTION.REPORT}${reportID}` as const);
@@ -93,6 +91,7 @@ function ProfilePage({route}: ProfilePageProps) {
9391
const {translate, formatPhoneNumber} = useLocalize();
9492

9593
const isValidAccountID = isValidAccountRoute(accountID);
94+
const loginParams = route.params?.login;
9695

9796
let details: OnyxEntry<PersonalDetails>;
9897
// Check if we have the personal details already in Onyx
@@ -167,9 +166,7 @@ function ProfilePage({route}: ProfilePageProps) {
167166

168167
// If it's a self DM, we only want to show the Message button if the self DM report exists because we don't want to optimistically create a report for self DM
169168
if ((!isCurrentUser || report) && !isAnonymousUserSession()) {
170-
promotedActions.push(
171-
PromotedActions.message({reportID: report?.reportID, personalDetails, accountID, login: loginParams, currentUserAccountID, introSelected, isSelfTourViewed, betas}),
172-
);
169+
promotedActions.push(PromotedActions.message({reportID: report?.reportID, accountID, login: loginParams, currentUserAccountID, introSelected, isSelfTourViewed, betas}));
173170
}
174171

175172
return (

0 commit comments

Comments
 (0)