diff --git a/src/components/AvatarWithDisplayName.tsx b/src/components/AvatarWithDisplayName.tsx index 076e2cb9e994..f863b5e15e84 100644 --- a/src/components/AvatarWithDisplayName.tsx +++ b/src/components/AvatarWithDisplayName.tsx @@ -192,10 +192,10 @@ function AvatarWithDisplayName({ const subtitle = getChatRoomSubtitle(report, {isCreateExpenseFlow: true}); const parentNavigationSubtitleData = getParentNavigationSubtitle(report, policy); const isMoneyRequestOrReport = isMoneyRequestReport(report) || isMoneyRequest(report) || isTrackExpenseReport(report) || isInvoiceReport(report); - const icons = getIcons(report, personalDetails, null, '', -1, policy, invoiceReceiverPolicy); + const isReportArchived = useReportIsArchived(report?.reportID); + const icons = getIcons(report, personalDetails, null, '', -1, policy, invoiceReceiverPolicy, isReportArchived); const ownerPersonalDetails = getPersonalDetailsForAccountIDs(report?.ownerAccountID ? [report.ownerAccountID] : [], personalDetails); const displayNamesWithTooltips = getDisplayNamesWithTooltips(Object.values(ownerPersonalDetails), false); - const isReportArchived = useReportIsArchived(report?.reportID); const shouldShowSubscriptAvatar = shouldReportShowSubscript(report, isReportArchived); const avatarBorderColor = avatarBorderColorProp ?? (isAnonymous ? theme.highlightBG : theme.componentBG); diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index d353bca7f4b4..e6f3b41189d0 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -26,7 +26,7 @@ import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTop import type {PlatformStackNavigationProp} from '@libs/Navigation/PlatformStackNavigation/types'; import Performance from '@libs/Performance'; import {getIOUActionForTransactionID, isExportIntegrationAction, isIntegrationMessageAction} from '@libs/ReportActionsUtils'; -import {canEditFieldOfMoneyRequest, generateReportID} from '@libs/ReportUtils'; +import {canEditFieldOfMoneyRequest, generateReportID, isArchivedReport} from '@libs/ReportUtils'; import {buildCannedSearchQuery, buildSearchQueryString} from '@libs/SearchQueryUtils'; import { getColumnsToShow, @@ -44,7 +44,7 @@ import { shouldShowEmptyState, shouldShowYear as shouldShowYearUtil, } from '@libs/SearchUIUtils'; -import type {SearchKey} from '@libs/SearchUIUtils'; +import type {ArchivedReportsIDSet, SearchKey} from '@libs/SearchUIUtils'; import {isOnHold, isTransactionPendingDelete} from '@libs/TransactionUtils'; import Navigation, {navigationRef} from '@navigation/Navigation'; import type {SearchFullscreenNavigatorParamList} from '@navigation/types'; @@ -171,6 +171,26 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: true}); const previousTransactions = usePrevious(transactions); const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {canBeMissing: true}); + + const [archivedReportsIdSet = new Set()] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { + canBeMissing: true, + selector: (all): ArchivedReportsIDSet => { + const ids = new Set(); + if (!all) { + return ids; + } + + const prefixLength = ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS.length; + for (const [key, value] of Object.entries(all)) { + if (isArchivedReport(value)) { + const reportID = key.slice(prefixLength); + ids.add(reportID); + } + } + return ids; + }, + }); + // Create a selector for only the reportActions needed to determine if a report has been exported or not, grouped by report const [exportReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, { canEvict: false, @@ -305,9 +325,8 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS if (groupBy && (isChat || isTask)) { return []; } - - return getSections(type, searchResults.data, searchResults.search, groupBy, exportReportActions, searchKey); - }, [searchKey, exportReportActions, groupBy, isDataLoaded, searchResults, type]); + return getSections(type, searchResults.data, searchResults.search, groupBy, exportReportActions, searchKey, archivedReportsIdSet); + }, [searchKey, exportReportActions, groupBy, isDataLoaded, searchResults, type, archivedReportsIdSet]); useEffect(() => { /** We only want to display the skeleton for the status filters the first time we load them for a specific data type */ diff --git a/src/hooks/useReportAvatarDetails.ts b/src/hooks/useReportAvatarDetails.ts index 8ce24c1bc19e..eedf582ff447 100644 --- a/src/hooks/useReportAvatarDetails.ts +++ b/src/hooks/useReportAvatarDetails.ts @@ -23,6 +23,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetailsList, Policy, Report, ReportAction, Transaction} from '@src/types/onyx'; import type {Icon} from '@src/types/onyx/OnyxCommon'; import useOnyx from './useOnyx'; +import useReportIsArchived from './useReportIsArchived'; import useTransactionsAndViolationsForReport from './useTransactionsAndViolationsForReport'; type ReportAvatarDetails = { @@ -72,11 +73,11 @@ function getIconDetails({ reportPreviewSenderID, innerPolicies, policy, -}: AvatarDetailsProps & {reportPreviewSenderID: number | undefined}) { + isReportArchived = false, +}: AvatarDetailsProps & {reportPreviewSenderID: number | undefined; isReportArchived?: boolean}) { const delegatePersonalDetails = action?.delegateAccountID ? personalDetails?.[action?.delegateAccountID] : undefined; const actorAccountID = getReportActionActorAccountID(action, iouReport, report, delegatePersonalDetails); const accountID = reportPreviewSenderID ?? actorAccountID ?? CONST.DEFAULT_NUMBER_ID; - const activePolicies = policies ?? innerPolicies; const ownerAccountID = iouReport?.ownerAccountID ?? action?.childOwnerAccountID; @@ -177,7 +178,7 @@ function getIconDetails({ if (!isWorkspaceActor) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const avatarIconIndex = report?.isOwnPolicyExpenseChat || isPolicyExpenseChat(report) ? 0 : 1; - const reportIcons = getIcons(report, personalDetails, undefined, undefined, undefined, policy); + const reportIcons = getIcons(report, personalDetails, undefined, undefined, undefined, policy, undefined, isReportArchived); return reportIcons.at(avatarIconIndex) ?? defaultAvatar; } @@ -221,6 +222,7 @@ function useReportAvatarDetails({iouReport, report, action, ...rest}: AvatarDeta canBeMissing: true, selector: (actions) => Object.values(actions ?? {}).filter(isMoneyRequestAction), }); + const isReportArchived = useReportIsArchived(report?.reportID); const {transactions: reportTransactions} = useTransactionsAndViolationsForReport(action?.childReportID); const transactions = useMemo(() => getAllNonDeletedTransactions(reportTransactions, iouActions ?? []), [reportTransactions, iouActions]); @@ -243,6 +245,7 @@ function useReportAvatarDetails({iouReport, report, action, ...rest}: AvatarDeta report, iouReport, reportPreviewSenderID: undefined, + isReportArchived, }), }; } @@ -280,6 +283,7 @@ function useReportAvatarDetails({iouReport, report, action, ...rest}: AvatarDeta report, iouReport, reportPreviewSenderID, + isReportArchived, }), }; } diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 70f618e08e2d..812c12e0b3fd 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1033,7 +1033,7 @@ function createOption( } result.text = reportName; - result.icons = getIcons(report, personalDetails, personalDetail?.avatar, personalDetail?.login, personalDetail?.accountID, null); + result.icons = getIcons(report, personalDetails, personalDetail?.avatar, personalDetail?.login, personalDetail?.accountID, null, undefined, !!result?.private_isArchived); result.subtitle = subtitle; return result; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0baddce2e51b..e7262a6c0750 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3252,6 +3252,7 @@ function getIcons( defaultAccountID = -1, policy?: OnyxInputOrEntry, invoiceReceiverPolicy?: OnyxInputOrEntry, + isReportArchived = false, ): Icon[] { if (isEmptyObject(report)) { return [ @@ -3275,15 +3276,7 @@ function getIcons( if (isDomainRoom(report)) { return getIconsForDomainRoom(report); } - const reportNameValuePairs = allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`]; - // This will get removed as part of https://github.com/Expensify/App/issues/59961 - // eslint-disable-next-line deprecation/deprecation - if ( - isAdminRoom(report) || - isAnnounceRoom(report) || - isChatRoom(report) || - (isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived) && !chatIncludesConcierge(report)) - ) { + if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || (isArchivedNonExpenseReport(report, isReportArchived) && !chatIncludesConcierge(report))) { return getIconsForPolicyRoom(report, personalDetails, policy, invoiceReceiverPolicy); } if (isPolicyExpenseChat(report)) { @@ -9613,30 +9606,6 @@ function getOptimisticDataForParentReportAction(reportID: string | undefined, la }); } -function getQuickActionDetails( - quickActionReport: Report, - personalDetails: PersonalDetailsList | undefined, - policyChatForActivePolicy: Report | undefined, - reportNameValuePairs: ReportNameValuePairs, -): {quickActionAvatars: Icon[]; hideQABSubtitle: boolean} { - const isValidQuickActionReport = !(isEmptyObject(quickActionReport) || isArchivedReport(reportNameValuePairs)); - let hideQABSubtitle = false; - let quickActionAvatars: Icon[] = []; - if (isValidQuickActionReport) { - const avatars = getIcons(quickActionReport, personalDetails); - quickActionAvatars = avatars.length <= 1 || isPolicyExpenseChat(quickActionReport) ? avatars : avatars.filter((avatar) => avatar.id !== currentUserAccountID); - } else { - hideQABSubtitle = true; - } - if (!isEmptyObject(policyChatForActivePolicy)) { - quickActionAvatars = getIcons(policyChatForActivePolicy, personalDetails); - } - return { - quickActionAvatars, - hideQABSubtitle, - }; -} - function canBeAutoReimbursed(report: OnyxInputOrEntry, policy: OnyxInputOrEntry | SearchPolicy): boolean { if (isEmptyObject(policy)) { return false; @@ -11408,7 +11377,6 @@ export { getInvoicePayerName, getInvoicesChatName, getPayeeName, - getQuickActionDetails, hasActionWithErrorsForTransaction, hasAutomatedExpensifyAccountIDs, hasExpensifyGuidesEmails, diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index b48e0857a813..5b660a962a2c 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -227,6 +227,8 @@ type SearchDateModifier = ValueOf; type SearchDateModifierLower = Lowercase; +type ArchivedReportsIDSet = ReadonlySet; + /** * Returns a list of all possible searches in the LHN, along with their query & hash. * *NOTE* When rendering the LHN, you should use the "createTypeMenuSections" method, which @@ -1021,7 +1023,7 @@ function getAction( * * Do not use directly, use only via `getSections()` facade. */ -function getTaskSections(data: OnyxTypes.SearchResults['data']): TaskListItemType[] { +function getTaskSections(data: OnyxTypes.SearchResults['data'], archivedReportsIDList?: ArchivedReportsIDSet): TaskListItemType[] { return ( Object.keys(data) .filter(isReportEntry) @@ -1061,7 +1063,8 @@ function getTaskSections(data: OnyxTypes.SearchResults['data']): TaskListItemTyp // eslint-disable-next-line deprecation/deprecation const policy = getPolicy(parentReport.policyID); const parentReportName = getReportName(parentReport, policy, undefined, undefined); - const icons = getIcons(parentReport, personalDetails, null, '', -1, policy); + const isParentReportArchived = archivedReportsIDList?.has(parentReport?.reportID); + const icons = getIcons(parentReport, personalDetails, null, '', -1, policy, undefined, isParentReportArchived); const parentReportIcon = icons?.at(0); result.parentReportName = parentReportName; @@ -1275,12 +1278,13 @@ function getSections( groupBy?: SearchGroupBy, reportActions: Record = {}, currentSearch: SearchKey = CONST.SEARCH.SEARCH_KEYS.EXPENSES, + archivedReportsIDList?: ArchivedReportsIDSet, ) { if (type === CONST.SEARCH.DATA_TYPES.CHAT) { return getReportActionsSections(data); } if (type === CONST.SEARCH.DATA_TYPES.TASK) { - return getTaskSections(data); + return getTaskSections(data, archivedReportsIDList); } if (groupBy) { @@ -1883,4 +1887,4 @@ export { isTransactionAmountTooLong, isTransactionTaxAmountTooLong, }; -export type {SavedSearchMenuItem, SearchTypeMenuSection, SearchTypeMenuItem, SearchDateModifier, SearchDateModifierLower, SearchKey}; +export type {SavedSearchMenuItem, SearchTypeMenuSection, SearchTypeMenuItem, SearchDateModifier, SearchDateModifierLower, SearchKey, ArchivedReportsIDSet}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 40a4747a6c10..56fa4fd82927 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -820,7 +820,16 @@ function getOptionData({ result.subtitle = subtitle; result.participantsList = participantPersonalDetailList; - result.icons = getIcons(report, personalDetails, personalDetail?.avatar, personalDetail?.login, personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID, policy, invoiceReceiverPolicy); + result.icons = getIcons( + report, + personalDetails, + personalDetail?.avatar, + personalDetail?.login, + personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID, + policy, + invoiceReceiverPolicy, + !!result.private_isArchived, + ); result.displayNamesWithTooltips = displayNamesWithTooltips; if (status) { diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index c3a822c7c709..c1b058146e0a 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -558,7 +558,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail return getDisplayNamesWithTooltips(getPersonalDetailsForAccountIDs(participants, personalDetails), hasMultipleParticipants); }, [participants, personalDetails]); - const icons = useMemo(() => getIcons(report, personalDetails, null, '', -1, policy), [report, personalDetails, policy]); + const icons = useMemo(() => getIcons(report, personalDetails, null, '', -1, policy, undefined, isReportArchived), [report, personalDetails, policy, isReportArchived]); const chatRoomSubtitleText = chatRoomSubtitle ? ( shouldShowDiscountBanner(hasTeam2025Pricing, subscriptionPlan) && !isArchivedReport(reportNameValuePairs), + () => shouldShowDiscountBanner(hasTeam2025Pricing, subscriptionPlan) && !isReportArchived, // eslint-disable-next-line react-compiler/react-compiler // eslint-disable-next-line react-hooks/exhaustive-deps [firstDayFreeTrial, lastDayFreeTrial, hasTeam2025Pricing, reportNameValuePairs, subscriptionPlan], ); - const isArchived = isArchivedReport(reportNameValuePairs); - const shouldShowSubscript = shouldReportShowSubscript(report, isArchived); + const shouldShowSubscript = shouldReportShowSubscript(report, isReportArchived); const defaultSubscriptSize = isExpenseRequest(report) ? CONST.AVATAR_SIZE.SMALL_NORMAL : CONST.AVATAR_SIZE.DEFAULT; - const icons = getIcons(reportHeaderData, personalDetails, null, '', -1, policy, invoiceReceiverPolicy); + const icons = getIcons(reportHeaderData, personalDetails, null, '', -1, policy, invoiceReceiverPolicy, isReportArchived); const brickRoadIndicator = hasReportNameError(report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; const shouldDisableDetailPage = shouldDisableDetailPageReportUtils(report); const shouldUseGroupTitle = isGroupChat && (!!report?.reportName || !isMultipleParticipant); @@ -225,7 +223,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked, const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, {canBeMissing: true}); const isChatUsedForOnboarding = isChatUsedForOnboardingReportUtils(report, onboardingPurposeSelected); const shouldShowRegisterForWebinar = introSelected?.companySize === CONST.ONBOARDING_COMPANY_SIZE.MICRO && (isChatUsedForOnboarding || (isAdminRoom(report) && !isChatThread)); - const shouldShowOnBoardingHelpDropdownButton = (shouldShowRegisterForWebinar || shouldShowGuideBooking) && !isArchived; + const shouldShowOnBoardingHelpDropdownButton = (shouldShowRegisterForWebinar || shouldShowGuideBooking) && !isReportArchived; const shouldShowEarlyDiscountBanner = shouldShowDiscount && isChatUsedForOnboarding; const latestScheduledCall = reportNameValuePairs?.calendlyCalls?.at(-1); const hasActiveScheduledCall = latestScheduledCall && !isPast(latestScheduledCall.eventTime) && latestScheduledCall.status !== CONST.SCHEDULE_CALL_STATUS.CANCELLED; @@ -302,7 +300,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked, tooltipEnabled numberOfLines={1} textStyles={[styles.headerText, styles.pre]} - shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isChatThread || isTaskReport || shouldUseGroupTitle || isArchived} + shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isChatThread || isTaskReport || shouldUseGroupTitle || isReportArchived} renderAdditionalText={renderAdditionalText} shouldAddEllipsis={shouldAddEllipsis} /> diff --git a/src/pages/home/report/ReportActionItemCreated.tsx b/src/pages/home/report/ReportActionItemCreated.tsx index e5da3655509a..2a03648e935d 100644 --- a/src/pages/home/report/ReportActionItemCreated.tsx +++ b/src/pages/home/report/ReportActionItemCreated.tsx @@ -6,6 +6,7 @@ import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeed import ReportWelcomeText from '@components/ReportWelcomeText'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; +import useReportIsArchived from '@hooks/useReportIsArchived'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; @@ -34,12 +35,13 @@ function ReportActionItemCreated({reportID, policyID}: ReportActionItemCreatedPr const [invoiceReceiverPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : undefined}`, { canBeMissing: true, }); + const isReportArchived = useReportIsArchived(report?.reportID); if (!isChatReport(report)) { return null; } - let icons = getIcons(report, personalDetails, null, '', -1, policy, invoiceReceiverPolicy); + let icons = getIcons(report, personalDetails, null, '', -1, policy, invoiceReceiverPolicy, isReportArchived); const shouldDisableDetailPage = shouldDisableDetailPageReportUtils(report); if (isInvoiceRoom(report) && isCurrentUserInvoiceReceiver(report)) { diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 22d4ba5609d3..c15b9b3db534 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -129,7 +129,8 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT const [travelSettings] = useOnyx(ONYXKEYS.NVP_TRAVEL_SETTINGS, {canBeMissing: true}); const canSendInvoice = useMemo(() => canSendInvoicePolicyUtils(allPolicies as OnyxCollection, session?.email), [allPolicies, session?.email]); - const isValidReport = !(isEmptyObject(quickActionReport) || isReportArchived); + const isArchivedReport = useReportIsArchived(quickActionReport?.reportID); + const isValidReport = !(isEmptyObject(quickActionReport) || isArchivedReport); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); const [hasSeenTour = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, { selector: hasSeenTourSelector, @@ -154,11 +155,11 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT const quickActionAvatars = useMemo(() => { if (isValidReport) { - const avatars = getIcons(quickActionReport, personalDetails); + const avatars = getIcons(quickActionReport, personalDetails, null, undefined, undefined, undefined, undefined, isArchivedReport); return avatars.length <= 1 || isPolicyExpenseChat(quickActionReport) ? avatars : avatars.filter((avatar) => avatar.id !== session?.accountID); } if (!isEmptyObject(policyChatForActivePolicy)) { - return getIcons(policyChatForActivePolicy, personalDetails); + return getIcons(policyChatForActivePolicy, personalDetails, null, undefined, undefined, undefined, undefined, isArchivedReport); } return []; // Policy is needed as a dependency in order to update the shortcut details when the workspace changes diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index a21eeeb405f8..45a2c9bd7ae5 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -36,6 +36,7 @@ import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; import usePrevious from '@hooks/usePrevious'; +import useReportIsArchived from '@hooks/useReportIsArchived'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useSingleExecution from '@hooks/useSingleExecution'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -128,6 +129,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); const currentUserPolicyExpenseChatReportID = getPolicyExpenseChat(accountID, policy?.id, allReports)?.reportID; const [currentUserPolicyExpenseChat] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${currentUserPolicyExpenseChatReportID}`, {canBeMissing: true}); + const isUserPolicyExpenseChatArchived = useReportIsArchived(currentUserPolicyExpenseChatReportID); const {reportPendingAction} = getReportOfflinePendingActionAndErrors(currentUserPolicyExpenseChat); const isPolicyExpenseChatEnabled = !!policy?.isPolicyExpenseChatEnabled; const prevPendingFields = usePrevious(policy?.pendingFields); @@ -495,7 +497,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(currentUserPolicyExpenseChat?.reportID))} shouldShowRightIcon wrapperStyle={[styles.br2, styles.pl2, styles.pr0, styles.pv3, styles.mt1, styles.alignItemsCenter]} diff --git a/tests/unit/ReportUtilsGetIconsTest.ts b/tests/unit/ReportUtilsGetIconsTest.ts index 05c35d317733..cb15a26c86b8 100644 --- a/tests/unit/ReportUtilsGetIconsTest.ts +++ b/tests/unit/ReportUtilsGetIconsTest.ts @@ -5,6 +5,7 @@ import { getIcons, isAdminRoom, isAnnounceRoom, + isArchivedNonExpenseReport, isChatReport, isChatRoom, isChatThread, @@ -144,6 +145,22 @@ describe('getIcons', () => { expect(icons.at(0)?.name).toBe('Email One'); }); + it('should return the correct icons for archived non expense request/report', () => { + const report: Report = { + ...LHNTestUtils.getFakeReport([1], 0, true), + type: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + }; + const policy = LHNTestUtils.getFakePolicy('1'); + + // Verify report type conditions + expect(isArchivedNonExpenseReport(report, true)).toBe(true); + + const icons = getIcons(report, FAKE_PERSONAL_DETAILS, null, '', -1, policy, undefined, true); + expect(icons).toHaveLength(1); + expect(icons.at(0)?.name).toBe(policy.name); + expect(icons.at(0)?.type).toBe('workspace'); + }); + it('should return the correct icons for a chat thread', () => { const report: Report = { ...LHNTestUtils.getFakeReport([1], 0, true), diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 5a1d0aeea008..d754432a5d7e 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -46,7 +46,6 @@ import { getMostRecentlyVisitedReport, getParticipantsList, getPolicyExpenseChat, - getQuickActionDetails, getReasonAndReportActionThatRequiresAttention, getReportIDFromLink, getReportName, @@ -1974,27 +1973,6 @@ describe('ReportUtils', () => { }); }); - describe('getQuickActionDetails', () => { - it('if the report is archived, the quick action will hide the subtitle and avatar', () => { - // Create a fake archived report as quick action report - const archivedReport: Report = { - ...LHNTestUtils.getFakeReport(), - reportID: '1', - }; - const reportNameValuePairs = { - type: 'chat', - private_isArchived: DateUtils.getDBTime(), - }; - - // Get the quick action detail - const quickActionDetails = getQuickActionDetails(archivedReport, undefined, undefined, reportNameValuePairs); - - // Expect the quickActionAvatars is empty array and hideQABSubtitle is true since the quick action report is archived - expect(quickActionDetails.quickActionAvatars.length).toEqual(0); - expect(quickActionDetails.hideQABSubtitle).toEqual(true); - }); - }); - describe('canEditMoneyRequest', () => { it('it should return false for archived invoice', async () => { const invoiceReport: Report = {