Skip to content

Commit 900489a

Browse files
Merge pull request Expensify#64614 from Expensify/tgolen-remove-rnvps-15
Remove a call to `getReportNameValuePairs()` in `shouldReportShowSubscript()`
2 parents e7e5cad + d125f83 commit 900489a

38 files changed

Lines changed: 494 additions & 87 deletions

src/components/AvatarWithDisplayName.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {ColorValue, TextStyle} from 'react-native';
44
import type {OnyxEntry} from 'react-native-onyx';
55
import type {ValueOf} from 'type-fest';
66
import useOnyx from '@hooks/useOnyx';
7+
import useReportIsArchived from '@hooks/useReportIsArchived';
78
import useStyleUtils from '@hooks/useStyleUtils';
89
import useTheme from '@hooks/useTheme';
910
import useThemeStyles from '@hooks/useThemeStyles';
@@ -188,7 +189,8 @@ function AvatarWithDisplayName({
188189
const icons = getIcons(report, personalDetails, null, '', -1, policy, invoiceReceiverPolicy);
189190
const ownerPersonalDetails = getPersonalDetailsForAccountIDs(report?.ownerAccountID ? [report.ownerAccountID] : [], personalDetails);
190191
const displayNamesWithTooltips = getDisplayNamesWithTooltips(Object.values(ownerPersonalDetails), false);
191-
const shouldShowSubscriptAvatar = shouldReportShowSubscript(report);
192+
const isReportArchived = useReportIsArchived(report?.reportID);
193+
const shouldShowSubscriptAvatar = shouldReportShowSubscript(report, isReportArchived);
192194
const avatarBorderColor = avatarBorderColorProp ?? (isAnonymous ? theme.highlightBG : theme.componentBG);
193195

194196
const actorAccountID = useRef<number | null>(null);

src/components/ReportWelcomeText.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
5050
const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report);
5151
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
5252
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID || undefined}`, {canBeMissing: true});
53+
const isReportArchived = useReportIsArchived(report?.reportID);
54+
const isArchivedRoom = isArchivedNonExpenseReport(report, isReportArchived);
5355
const isChatRoom = isChatRoomReportUtils(report);
5456
const isSelfDM = isSelfDMReportUtils(report);
5557
const isInvoiceRoom = isInvoiceRoomReportUtils(report);
@@ -59,9 +61,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
5961
const participantAccountIDs = getParticipantsAccountIDsForDisplay(report, undefined, true, true, reportMetadata);
6062
const isMultipleParticipant = participantAccountIDs.length > 1;
6163
const displayNamesWithTooltips = getDisplayNamesWithTooltips(getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant);
62-
const isReportArchived = useReportIsArchived(report?.reportID);
6364
const welcomeMessage = SidebarUtils.getWelcomeMessage(report, policy, isReportArchived);
64-
const isArchivedRoom = isArchivedNonExpenseReport(report, isReportArchived);
6565
const moneyRequestOptions = temporary_getMoneyRequestOptions(report, policy, participantAccountIDs);
6666
const policyName = getPolicyName({report});
6767

src/libs/OptionsListUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ function createOption(accountIDs: number[], personalDetails: OnyxInputOrEntry<Pe
936936
result.isMoneyRequestReport = reportUtilsIsMoneyRequestReport(report);
937937
result.isThread = isChatThread(report);
938938
result.isTaskReport = reportUtilsIsTaskReport(report);
939-
result.shouldShowSubscript = shouldReportShowSubscript(report);
939+
result.shouldShowSubscript = shouldReportShowSubscript(report, !!result.private_isArchived);
940940
result.isPolicyExpenseChat = reportUtilsIsPolicyExpenseChat(report);
941941
result.isOwnPolicyExpenseChat = report.isOwnPolicyExpenseChat ?? false;
942942
result.allReportErrors = reportAttributesDerivedValue?.[report.reportID]?.reportErrors ?? {};

src/libs/ReportUtils.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,6 @@ function isClosedExpenseReportWithNoExpenses(report: OnyxEntry<Report>, transact
20422042
/**
20432043
* Whether the provided report is an archived room
20442044
*/
2045-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
20462045
function isArchivedNonExpenseReport(report: OnyxInputOrEntry<Report> | SearchReport, isReportArchived = false): boolean {
20472046
return isReportArchived && !(isExpenseReport(report) || isExpenseRequest(report));
20482047
}
@@ -8308,7 +8307,7 @@ function getInvoiceChatByParticipants(receiverID: string | number, receiverType:
83088307
// eslint-disable-next-line deprecation/deprecation
83098308
const reportNameValuePairs = getReportNameValuePairs(report?.reportID);
83108309
const isReportArchived = isArchivedReport(reportNameValuePairs);
8311-
if (!report || !isInvoiceRoom(report) || isArchivedNonExpenseReportWithID(report, isReportArchived)) {
8310+
if (!report || !isInvoiceRoom(report) || isArchivedNonExpenseReport(report, isReportArchived)) {
83128311
return false;
83138312
}
83148313

@@ -8747,10 +8746,8 @@ function getWhisperDisplayNames(participantAccountIDs?: number[]): string | unde
87478746
/**
87488747
* Show subscript on expense chats / threads and expense requests
87498748
*/
8750-
function shouldReportShowSubscript(report: OnyxEntry<Report>): boolean {
8751-
// This will get removed as part of https://github.com/Expensify/App/issues/59961
8752-
// eslint-disable-next-line deprecation/deprecation
8753-
if (isArchivedNonExpenseReport(report, !!getReportNameValuePairs(report?.reportID)?.private_isArchived) && !isWorkspaceThread(report)) {
8749+
function shouldReportShowSubscript(report: OnyxEntry<Report>, isReportArchived = false): boolean {
8750+
if (isArchivedNonExpenseReport(report, isReportArchived) && !isWorkspaceThread(report)) {
87548751
return false;
87558752
}
87568753

src/libs/SidebarUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ function getOptionData({
582582
result.isPolicyExpenseChat = isPolicyExpenseChat(report);
583583
result.isExpenseRequest = isExpenseRequest(report);
584584
result.isMoneyRequestReport = isMoneyRequestReport(report);
585-
result.shouldShowSubscript = shouldReportShowSubscript(report);
585+
result.shouldShowSubscript = shouldReportShowSubscript(report, !!result.private_isArchived);
586586
result.pendingAction = report.pendingFields?.addWorkspaceRoom ?? report.pendingFields?.createChat;
587587
result.brickRoadIndicator = reportAttributes?.brickRoadStatus;
588588
result.ownerAccountID = report.ownerAccountID;

src/pages/ReportParticipantsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function ReportParticipantsPage({report, route}: ReportParticipantsPageProps) {
7272
const selectionListRef = useRef<SelectionListHandle>(null);
7373
const textInputRef = useRef<TextInput>(null);
7474
const [userSearchPhrase] = useOnyx(ONYXKEYS.ROOM_MEMBERS_USER_SEARCH_PHRASE, {canBeMissing: true});
75+
const isReportArchived = useReportIsArchived(report?.reportID);
7576
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID}`, {canBeMissing: false});
7677
const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: (attributes) => attributes?.reports, canBeMissing: false});
7778
const {selectionMode} = useMobileSelectionMode();
@@ -84,7 +85,6 @@ function ReportParticipantsPage({report, route}: ReportParticipantsPageProps) {
8485
const {isOffline} = useNetwork();
8586
const canSelectMultiple = isGroupChat && isCurrentUserAdmin && (isSmallScreenWidth ? selectionMode?.isEnabled : true);
8687
const [searchValue, setSearchValue] = useState('');
87-
const isReportArchived = useReportIsArchived(report?.reportID);
8888

8989
const {chatParticipants, personalDetailsParticipants} = useMemo(
9090
() => getReportPersonalDetailsParticipants(report, personalDetails, reportMetadata),

src/pages/home/HeaderView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
210210
[firstDayFreeTrial, lastDayFreeTrial, hasTeam2025Pricing, reportNameValuePairs, subscriptionPlan],
211211
);
212212

213-
const shouldShowSubscript = shouldReportShowSubscript(report);
213+
const isArchived = isArchivedReport(reportNameValuePairs);
214+
const shouldShowSubscript = shouldReportShowSubscript(report, isArchived);
214215
const defaultSubscriptSize = isExpenseRequest(report) ? CONST.AVATAR_SIZE.SMALL_NORMAL : CONST.AVATAR_SIZE.DEFAULT;
215216
const icons = getIcons(reportHeaderData, personalDetails, null, '', -1, policy, invoiceReceiverPolicy);
216217
const brickRoadIndicator = hasReportNameError(report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '';
@@ -224,7 +225,6 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
224225
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, {canBeMissing: true});
225226
const isChatUsedForOnboarding = isChatUsedForOnboardingReportUtils(report, onboardingPurposeSelected);
226227
const shouldShowRegisterForWebinar = introSelected?.companySize === CONST.ONBOARDING_COMPANY_SIZE.MICRO && (isChatUsedForOnboarding || isAdminRoom(report));
227-
const isArchived = isArchivedReport(reportNameValuePairs);
228228
const shouldShowOnBoardingHelpDropdownButton = (shouldShowRegisterForWebinar || shouldShowGuideBooking) && !isArchived;
229229
const shouldShowEarlyDiscountBanner = shouldShowDiscount && isChatUsedForOnboarding;
230230
const latestScheduledCall = reportNameValuePairs?.calendlyCalls?.at(-1);

src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
chatIncludesChronosWithID,
2727
getSourceIDFromReportAction,
2828
isArchivedNonExpenseReport,
29-
isArchivedNonExpenseReportWithID,
3029
isInvoiceReport as ReportUtilsIsInvoiceReport,
3130
isMoneyRequest as ReportUtilsIsMoneyRequest,
3231
isMoneyRequestReport as ReportUtilsIsMoneyRequestReport,
@@ -190,9 +189,8 @@ function BaseReportActionContextMenu({
190189
}, [parentReportAction, isMoneyRequestReport, isInvoiceReport, paginatedReportActions, transactionThreadReport?.parentReportActionID]);
191190

192191
const moneyRequestAction = transactionThreadReportID ? requestParentReportAction : parentReportAction;
193-
194-
const [childReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${childReport?.reportID}`, {canBeMissing: true});
195-
const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${childReport?.parentReportID}`, {canBeMissing: true});
192+
const isChildReportArchived = useReportIsArchived(childReport?.reportID);
193+
const isParentReportArchived = useReportIsArchived(childReport?.parentReportID);
196194
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${childReport?.parentReportID}`, {canBeMissing: true});
197195

198196
const isMoneyRequest = useMemo(() => ReportUtilsIsMoneyRequest(childReport), [childReport]);
@@ -203,10 +201,7 @@ function BaseReportActionContextMenu({
203201
const areHoldRequirementsMet =
204202
!isInvoiceReport &&
205203
isMoneyRequestOrReport &&
206-
!isArchivedNonExpenseReport(
207-
transactionThreadReportID ? childReport : parentReport,
208-
transactionThreadReportID ? !!childReportNameValuePairs?.private_isArchived : !!parentReportNameValuePairs?.private_isArchived,
209-
);
204+
!isArchivedNonExpenseReport(transactionThreadReportID ? childReport : parentReport, transactionThreadReportID ? isChildReportArchived : isParentReportArchived);
210205

211206
const shouldEnableArrowNavigation = !isMini && (isVisible || shouldKeepOpen);
212207
let filteredContextMenuActions = ContextMenuActions.filter(
@@ -300,7 +295,7 @@ function BaseReportActionContextMenu({
300295
report: {
301296
reportID,
302297
originalReportID,
303-
isArchivedRoom: isArchivedNonExpenseReportWithID(originalReport, isOriginalReportArchived),
298+
isArchivedRoom: isArchivedNonExpenseReport(originalReport, isOriginalReportArchived),
304299
isChronos: chatIncludesChronosWithID(originalReportID),
305300
},
306301
reportAction: {

src/pages/home/report/PureReportActionItem.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,8 +1234,7 @@ function PureReportActionItem({
12341234
index={index}
12351235
ref={composerTextInputRef}
12361236
shouldDisableEmojiPicker={
1237-
(chatIncludesConcierge(report) && isBlockedFromConcierge(blockedFromConcierge)) ||
1238-
isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived)
1237+
(chatIncludesConcierge(report) && isBlockedFromConcierge(blockedFromConcierge)) || isArchivedNonExpenseReport(report, isArchivedRoom)
12391238
}
12401239
isGroupPolicyReport={!!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE}
12411240
/>

src/pages/home/report/ReportActionItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
getOriginalReportID,
1313
getReimbursementDeQueuedOrCanceledActionMessage,
1414
getTransactionsWithReceipts,
15-
isArchivedNonExpenseReportWithID,
15+
isArchivedNonExpenseReport,
1616
isChatThread,
1717
isClosedExpenseReportWithNoExpenses,
1818
isCurrentUserTheOnlyParticipant,
@@ -106,7 +106,7 @@ function ReportActionItem({allReports, action, report, transactions, shouldShowD
106106
blockedFromConcierge={blockedFromConcierge}
107107
originalReportID={originalReportID}
108108
deleteReportActionDraft={deleteReportActionDraft}
109-
isArchivedRoom={isArchivedNonExpenseReportWithID(originalReport, isOriginalReportArchived)}
109+
isArchivedRoom={isArchivedNonExpenseReport(originalReport, isOriginalReportArchived)}
110110
isChronosReport={chatIncludesChronosWithID(originalReportID)}
111111
toggleEmojiReaction={toggleEmojiReaction}
112112
createDraftTransactionAndNavigateToParticipantSelector={createDraftTransactionAndNavigateToParticipantSelector}

0 commit comments

Comments
 (0)