Skip to content

Commit 44fdf80

Browse files
committed
fix: refactor selector function and use buildParticipantsFromAccountIDs in test
1 parent cb8dd70 commit 44fdf80

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

src/libs/ReportUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7871,8 +7871,6 @@ function isIOUOwnedByCurrentUser(report: OnyxEntry<Report>, allReportsDict?: Ony
78717871
*/
78727872
function canSeeDefaultRoom(report: OnyxEntry<Report>, betas: OnyxEntry<Beta[]>, isReportArchived = false): boolean {
78737873
// Include archived rooms
7874-
// This will get removed as part of https://github.com/Expensify/App/issues/59961
7875-
// eslint-disable-next-line deprecation/deprecation
78767874
if (isArchivedNonExpenseReport(report, isReportArchived)) {
78777875
return true;
78787876
}

src/pages/home/report/ReportActionItemParentAction.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function ReportActionItemParentAction({
8383
const [allAncestors, setAllAncestors] = useState<Ancestor[]>([]);
8484
const {isOffline} = useNetwork();
8585
const {isInNarrowPaneModal} = useResponsiveLayout();
86-
const [reportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {
86+
const [ancestorReportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {
8787
canBeMissing: true,
8888
selector: (allPairs) => {
8989
const ancestorIDsToSelect = new Set(ancestorIDs.current.reportIDs);
@@ -139,7 +139,8 @@ function ReportActionItemParentAction({
139139
const ancestorReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${ancestor.report.reportID}`];
140140
const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(ancestorReport);
141141
const shouldDisplayThreadDivider = !isTripPreview(ancestor.reportAction);
142-
const reportNameValuePair = reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${ancestorReports.current?.[ancestor?.report?.reportID]?.reportID}`];
142+
const reportNameValuePair =
143+
ancestorReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${ancestorReports.current?.[ancestor?.report?.reportID]?.reportID}`];
143144
const isAncestorReportArchived = isArchivedReport(reportNameValuePair);
144145
return (
145146
<OfflineWithFeedback

tests/unit/ReportUtilsTest.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,10 +4935,7 @@ describe('ReportUtils', () => {
49354935
const betas = [CONST.BETAS.DEFAULT_ROOMS];
49364936
const report: Report = {
49374937
...createRandomReport(40002),
4938-
participants: {
4939-
'1': {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
4940-
'8': {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
4941-
},
4938+
participants: buildParticipantsFromAccountIDs([currentUserAccountID, 8]),
49424939
};
49434940
Onyx.set(ONYXKEYS.PERSONAL_DETAILS_LIST, personalDetails).then(() => {
49444941
expect(canSeeDefaultRoom(report, betas, false)).toBe(true);

0 commit comments

Comments
 (0)