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
12 changes: 5 additions & 7 deletions src/components/Search/FilterComponents/InSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,16 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
const reportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${reportData?.policyID}`];
const report = {
...getSelectedOptionData(
createOptionFromReport(
{...reportData, reportID: id},
createOptionFromReport({
report: {...reportData, reportID: id},
personalDetails,
privateIsArchived,
reportPolicy,
policy: reportPolicy,
sortedActions,
conciergeReportID,
reportAttributesDerived,
undefined,
undefined,
undefined,
isTrackIntentUser,
),
}),
),
isSelected,
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Search/SearchList/ListItem/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ type GroupChildrenContentProps = {
newTransactionID?: string;
bankAccountList?: OnyxEntry<BankAccountList>;
cardFeeds?: OnyxCollection<CardFeeds>;
conciergeReportID?: string;
conciergeReportID: string | undefined;
};

type UnreportedExpenseListItemType = Transaction & {
Expand Down
18 changes: 9 additions & 9 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
const currentUserAccountID = currentUserPersonalDetails.accountID;
const [isSearchingForReports] = useOnyx(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [guidedSetupAndTourStatus] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: guidedSetupAndTourStatusSelector});
const [searchContext] = useOnyx(ONYXKEYS.SEARCH_CONTEXT);
Expand Down Expand Up @@ -213,20 +214,18 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
return undefined;
}

const option = createOptionFromReport(
contextualReport,
const option = createOptionFromReport({
report: contextualReport,
personalDetails,
contextualReportNVP,
contextualReportPolicy,
privateIsArchived: contextualReportNVP,
policy: contextualReportPolicy,
sortedActions,
undefined,
{
conciergeReportID,
config: {
showPersonalDetails: true,
},
undefined,
undefined,
isTrackIntentUser,
);
});
reportForContextualSearch = option;
}

Expand Down Expand Up @@ -280,6 +279,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
},
[
contextualReportID,
conciergeReportID,
navigationSuggestions,
textInputValue,
isSearchRouterDisplayed,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Search/SearchStaticList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function SearchStaticList({
const email = session?.email;
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [hasCompletedGuidedSetupFlow] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasCompletedGuidedSetupFlowSelector});
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);

const [showPendingExpensePlaceholder, setShowPendingExpensePlaceholder] = useState(
() => hasDeferredWrite(CONST.DEFERRED_LAYOUT_WRITE_KEYS.SEARCH) || Navigation.getIsFullscreenPreInsertedUnderRHP(),
Expand All @@ -107,7 +108,7 @@ function SearchStaticList({
translate,
formatPhoneNumber,
bankAccountList: undefined,
conciergeReportID: undefined,
conciergeReportID,
convertToDisplayString,
reportAttributesDerivedValue: undefined,
});
Expand Down
10 changes: 3 additions & 7 deletions src/hooks/useFilteredOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function useFilteredOptions(config: UseFilteredOptionsConfig = {}): UseFilteredO
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const reportAttributesDerived = useReportAttributes();
const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});

Expand All @@ -106,13 +107,7 @@ function useFilteredOptions(config: UseFilteredOptionsConfig = {}): UseFilteredO
reportAttributesDerived,
privateIsArchivedMap,
allPolicies,
{
maxRecentReports: reportsLimit,
includeP2P,
isSearching,
deferContactsUntilSearch,
locale: preferredLocale,
},
{conciergeReportID, maxRecentReports: reportsLimit, includeP2P, isSearching, deferContactsUntilSearch, locale: preferredLocale},
undefined,
undefined,
isTrackIntentUser,
Expand All @@ -126,6 +121,7 @@ function useFilteredOptions(config: UseFilteredOptionsConfig = {}): UseFilteredO
reportAttributesDerived,
privateIsArchivedMap,
allPolicies,
conciergeReportID,
reportsLimit,
includeP2P,
isSearching,
Expand Down
100 changes: 70 additions & 30 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,7 @@ function getLastMessageTextForReport({
reportAttributesDerived?: ReportAttributesDerivedValue['reports'];
policyTags?: OnyxEntry<PolicyTagLists>;
currentUserLogin?: string;
// TODO: conciergeReportID will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/66411
conciergeReportID?: string;
conciergeReportID: string | undefined;
isTrackIntentUser?: boolean;
// TODO: Remove optional (?) once all callers pass sortedActions. Refactor issue: https://github.com/Expensify/App/issues/66381
sortedActions?: Record<string, ReportAction[]>;
Expand Down Expand Up @@ -1089,8 +1088,7 @@ type CreateOptionParams = {
visibleReportActionsData?: VisibleReportActionsDerivedValue;
translate?: LocalizedTranslate;
isTrackIntentUser?: boolean;
// TODO: conciergeReportID will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/66411
conciergeReportID?: string;
conciergeReportID: string | undefined;
// TODO: Remove optional (?) once all callers pass sortedActions. Refactor issue: https://github.com/Expensify/App/issues/66381
sortedActions?: Record<string, ReportAction[]>;
// TODO: Remove optional (?) once all callers pass currentUserAccountID. Refactor issue: https://github.com/Expensify/App/issues/66408
Expand Down Expand Up @@ -1331,21 +1329,36 @@ function getReportOption(
return option;
}

type GetReportDisplayOptionParams = {
report: OnyxEntry<Report>;
unknownUserDetails: OnyxEntry<Participant>;
personalDetails: OnyxEntry<PersonalDetailsList>;
privateIsArchived: boolean | undefined;
policy: OnyxEntry<Policy>;
conciergeReportID: string | undefined;
translate: LocalizedTranslate;
currentUserAccountID: number;
reportAttributesDerived?: ReportAttributesDerivedValue['reports'];
policyTags?: OnyxEntry<PolicyTagLists>;
visibleReportActionsData?: VisibleReportActionsDerivedValue;
};

/**
* Get the display option for a given report.
*/
function getReportDisplayOption(
report: OnyxEntry<Report>,
unknownUserDetails: OnyxEntry<Participant>,
personalDetails: OnyxEntry<PersonalDetailsList>,
privateIsArchived: boolean | undefined,
policy: OnyxEntry<Policy>,
translate: LocalizedTranslate,
currentUserAccountID: number,
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
policyTags?: OnyxEntry<PolicyTagLists>,
visibleReportActionsData: VisibleReportActionsDerivedValue = {},
): OptionData {
function getReportDisplayOption({
report,
unknownUserDetails,
personalDetails,
privateIsArchived,
policy,
conciergeReportID,
translate,
currentUserAccountID,
reportAttributesDerived,
policyTags,
visibleReportActionsData = {},
}: GetReportDisplayOptionParams): OptionData {
const visibleParticipantAccountIDs = getParticipantsAccountIDsForDisplay(report, true);

const option = createOption({
Expand All @@ -1354,6 +1367,7 @@ function getReportDisplayOption(
report: !isEmptyObject(report) ? report : undefined,
policy,
privateIsArchived,
conciergeReportID,
config: {
showChatPreviewLine: false,
forcePolicyNamePreview: false,
Expand Down Expand Up @@ -1409,6 +1423,8 @@ function getPolicyExpenseReportOption(
report: !isEmptyObject(expenseReport) ? expenseReport : null,
policy,
privateIsArchived,
// Passing conciergeReportID as undefined is intentional, a policy expense chat is never the Concierge chat.
conciergeReportID: undefined,
config: {
showChatPreviewLine: false,
forcePolicyNamePreview: false,
Expand Down Expand Up @@ -1527,6 +1543,7 @@ function processReport(
personalDetails: OnyxEntry<PersonalDetailsList>,
privateIsArchived: boolean | undefined,
policy: OnyxEntry<Policy>,
conciergeReportID: string | undefined,
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
policyTags?: OnyxEntry<PolicyTagLists>,
visibleReportActionsData: VisibleReportActionsDerivedValue = {},
Expand Down Expand Up @@ -1562,6 +1579,7 @@ function processReport(
report,
privateIsArchived,
policy,
conciergeReportID,
reportAttributesDerived,
policyTags,
visibleReportActionsData,
Expand Down Expand Up @@ -1676,6 +1694,7 @@ function createFilteredOptionList(
privateIsArchivedMap: PrivateIsArchivedMap,
policiesCollection: OnyxCollection<Policy>,
options: {
conciergeReportID: string | undefined;
maxRecentReports?: number;
includeP2P?: boolean;
isSearching?: boolean;
Expand All @@ -1687,14 +1706,14 @@ function createFilteredOptionList(
*/
deferContactsUntilSearch?: boolean;
locale?: Locale;
} = {},
},
policyTags?: OnyxCollection<PolicyTagLists>,
visibleReportActionsData: VisibleReportActionsDerivedValue = EMPTY_VISIBLE_REPORT_ACTIONS,
isTrackIntentUser?: boolean,
// TODO: Remove optional (?) once all callers pass sortedActions. Refactor issue: https://github.com/Expensify/App/issues/66381
sortedActions?: Record<string, ReportAction[]>,
): OptionList {
const {maxRecentReports = 500, includeP2P = true, isSearching = false, deferContactsUntilSearch = false, locale} = options;
const {conciergeReportID, maxRecentReports = 500, includeP2P = true, isSearching = false, deferContactsUntilSearch = false, locale} = options;
Comment thread
cretadn22 marked this conversation as resolved.

// Contacts are expensive to build on large accounts (one option per personal detail). When a screen
// opts into deferral and is not actively searching, skip building them entirely; the empty state
Expand All @@ -1716,6 +1735,7 @@ function createFilteredOptionList(
policyTags,
visibleReportActionsData,
isTrackIntentUser,
conciergeReportID,
// Option building translates strings imperatively (translateLocal), so the active locale is part of the output.
locale ?? IntlStore.getCurrentLocale(),
// The RAM_ONLY_SORTED_REPORT_ACTIONS derived value produces a new object on every recompute,
Expand Down Expand Up @@ -1779,6 +1799,7 @@ function createFilteredOptionList(
personalDetails,
privateIsArchived,
policy,
conciergeReportID,
reportAttributesDerived,
reportPolicyTags,
visibleReportActionsData,
Expand Down Expand Up @@ -1823,6 +1844,7 @@ function createFilteredOptionList(
report: reportMapForAccountIDs[accountID],
policy,
privateIsArchived,
conciergeReportID,
config: {showPersonalDetails: true},
reportAttributesDerived,
policyTags: reportPolicyTags,
Expand Down Expand Up @@ -1858,18 +1880,33 @@ function createFilteredOptionList(
return cloneOptionList(result);
}

function createOptionFromReport(
report: Report,
personalDetails: OnyxEntry<PersonalDetailsList>,
privateIsArchived: boolean | undefined,
policy: OnyxEntry<Policy>,
sortedActions: Record<string, ReportAction[]> | undefined,
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
config?: PreviewConfig,
policyTags?: OnyxEntry<PolicyTagLists>,
visibleReportActionsData: VisibleReportActionsDerivedValue = {},
isTrackIntentUser?: boolean,
) {
type CreateOptionFromReportParams = {
report: Report;
personalDetails: OnyxEntry<PersonalDetailsList>;
privateIsArchived: boolean | undefined;
policy: OnyxEntry<Policy>;
sortedActions: Record<string, ReportAction[]> | undefined;
conciergeReportID: string | undefined;
reportAttributesDerived?: ReportAttributesDerivedValue['reports'];
config?: PreviewConfig;
policyTags?: OnyxEntry<PolicyTagLists>;
visibleReportActionsData?: VisibleReportActionsDerivedValue;
isTrackIntentUser?: boolean;
};

function createOptionFromReport({
report,
personalDetails,
privateIsArchived,
policy,
sortedActions,
conciergeReportID,
reportAttributesDerived,
config,
policyTags,
visibleReportActionsData = {},
isTrackIntentUser,
}: CreateOptionFromReportParams) {
const accountIDs = getParticipantsAccountIDsForDisplay(report);

return {
Expand All @@ -1880,6 +1917,7 @@ function createOptionFromReport(
report,
privateIsArchived,
policy,
conciergeReportID,
config,
reportAttributesDerived,
policyTags,
Expand Down Expand Up @@ -2233,6 +2271,8 @@ function getUserToInviteOption({
personalDetails: personalDetailsExtended,
report: null,
privateIsArchived: undefined,
// Passing conciergeReportID as undefined is intentional, the invite option is built without a report, so it can never be the Concierge chat.
conciergeReportID: undefined,
config: {showChatPreviewLine},
visibleReportActionsData,
});
Expand Down
3 changes: 1 addition & 2 deletions src/libs/ReportNameUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ type ComputeReportName = {
currentUserAccountID?: number;
currentUserLogin: string;
translate: LocalizedTranslate;
// TODO: Make this required when https://github.com/Expensify/App/issues/66411 is done
conciergeReportID?: string;
conciergeReportID: string | undefined;
reportAttributes?: ReportAttributesDerivedValue['reports'];
isTrackIntentUser: boolean | undefined;
};
Expand Down
1 change: 1 addition & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ function getOptionData({
report,
personalDetails,
lastActorDetails,
conciergeReportID,
movedFromReport,
movedToReport,
policy,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ type BuildPolicyDataOptions = {
currentUserAccountIDParam: number;
currentUserEmailParam: string;
allReportsParam?: OnyxCollection<Report>;
/** The Concierge chat report, threaded so prepareOnboardingOnyxData no longer relies on the deprecated CONCIERGE_REPORT_ID Onyx.connect (#66411). */
conciergeChat: OnyxEntry<Report>;
// TODO: Make conciergeChat required once all callers pass it. Refactor issue: https://github.com/Expensify/App/issues/66411
conciergeChat?: OnyxEntry<Report>;
onboardingPurposeSelected?: OnboardingPurpose;
shouldAddGuideWelcomeMessage?: boolean;
shouldCreateControlPolicy?: boolean;
Expand Down
Loading
Loading