Skip to content

Commit 9e40aec

Browse files
committed
Rename hook to useDismissOnMoneyRequestReportRemoval
1 parent 49947ce commit 9e40aec

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

Mobile-Expensify

src/hooks/useDismissOnReportRemoval.ts renamed to src/hooks/useDismissOnMoneyRequestReportRemoval.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import usePrevious from './usePrevious';
1111
* Skips dismissal during route changes — the new report's data may not be loaded yet,
1212
* so the absent `report` should not be interpreted as removal.
1313
*/
14-
function useDismissOnReportRemoval(reportIDFromRoute: string | undefined) {
14+
function useDismissOnMoneyRequestReportRemoval(reportIDFromRoute: string | undefined) {
1515
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportIDFromRoute}`);
1616
const prevReport = usePrevious(report);
1717
const prevReportIDFromRoute = usePrevious(reportIDFromRoute);
@@ -39,4 +39,4 @@ function useDismissOnReportRemoval(reportIDFromRoute: string | undefined) {
3939
}, [report, isFocused, prevReport, prevReportIDFromRoute, reportIDFromRoute]);
4040
}
4141

42-
export default useDismissOnReportRemoval;
42+
export default useDismissOnMoneyRequestReportRemoval;

src/pages/Search/SearchMoneyRequestReportPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import useShowSuperWideRHPVersion from '@components/WideRHPContextProvider/useSh
1313
import WideRHPOverlayWrapper from '@components/WideRHPOverlayWrapper';
1414
import useActionListContextValue from '@hooks/useActionListContextValue';
1515
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
16-
import useDismissOnReportRemoval from '@hooks/useDismissOnReportRemoval';
16+
import useDismissOnMoneyRequestReportRemoval from '@hooks/useDismissOnMoneyRequestReportRemoval';
1717
import useDocumentTitle from '@hooks/useDocumentTitle';
1818
import useIsReportReadyToDisplay from '@hooks/useIsReportReadyToDisplay';
1919
import useNetwork from '@hooks/useNetwork';
@@ -88,7 +88,7 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) {
8888
const {email: currentUserEmail, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
8989
const isFocused = useIsFocused();
9090

91-
useDismissOnReportRemoval(reportIDFromRoute);
91+
useDismissOnMoneyRequestReportRemoval(reportIDFromRoute);
9292

9393
useEffect(() => {
9494
// Update last visit time when the expense super wide RHP report is focused

tests/unit/hooks/useDismissOnReportRemoval.test.ts renamed to tests/unit/hooks/useDismissOnMoneyRequestReportRemoval.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type * as ReactNavigation from '@react-navigation/native';
22
import {renderHook} from '@testing-library/react-native';
33
import Onyx from 'react-native-onyx';
4-
import useDismissOnReportRemoval from '@hooks/useDismissOnReportRemoval';
4+
import useDismissOnMoneyRequestReportRemoval from '@hooks/useDismissOnMoneyRequestReportRemoval';
55
import Navigation from '@navigation/Navigation';
66
import CONST from '@src/CONST';
77
import ONYXKEYS from '@src/ONYXKEYS';
@@ -41,7 +41,7 @@ function buildChatReport(id: string): Report {
4141
} as Report;
4242
}
4343

44-
describe('useDismissOnReportRemoval', () => {
44+
describe('useDismissOnMoneyRequestReportRemoval', () => {
4545
beforeAll(() => {
4646
Onyx.init({keys: ONYXKEYS});
4747
});
@@ -57,7 +57,7 @@ describe('useDismissOnReportRemoval', () => {
5757
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_A_ID}`, buildMoneyRequestReport(REPORT_A_ID));
5858
await waitForBatchedUpdates();
5959

60-
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnReportRemoval(reportID), {
60+
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnMoneyRequestReportRemoval(reportID), {
6161
initialProps: {reportID: REPORT_A_ID},
6262
});
6363

@@ -69,7 +69,7 @@ describe('useDismissOnReportRemoval', () => {
6969
});
7070

7171
it('does not dismiss the modal on first render even if the report is missing', async () => {
72-
renderHook(({reportID}: {reportID: string}) => useDismissOnReportRemoval(reportID), {
72+
renderHook(({reportID}: {reportID: string}) => useDismissOnMoneyRequestReportRemoval(reportID), {
7373
initialProps: {reportID: REPORT_A_ID},
7474
});
7575
await waitForBatchedUpdates();
@@ -82,7 +82,7 @@ describe('useDismissOnReportRemoval', () => {
8282
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_A_ID}`, buildMoneyRequestReport(REPORT_A_ID));
8383
await waitForBatchedUpdates();
8484

85-
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnReportRemoval(reportID), {
85+
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnMoneyRequestReportRemoval(reportID), {
8686
initialProps: {reportID: REPORT_A_ID},
8787
});
8888

@@ -97,7 +97,7 @@ describe('useDismissOnReportRemoval', () => {
9797
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_A_ID}`, buildChatReport(REPORT_A_ID));
9898
await waitForBatchedUpdates();
9999

100-
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnReportRemoval(reportID), {
100+
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnMoneyRequestReportRemoval(reportID), {
101101
initialProps: {reportID: REPORT_A_ID},
102102
});
103103

@@ -115,7 +115,7 @@ describe('useDismissOnReportRemoval', () => {
115115
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_A_ID}`, buildMoneyRequestReport(REPORT_A_ID));
116116
await waitForBatchedUpdates();
117117

118-
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnReportRemoval(reportID), {
118+
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnMoneyRequestReportRemoval(reportID), {
119119
initialProps: {reportID: REPORT_A_ID},
120120
});
121121

@@ -132,7 +132,7 @@ describe('useDismissOnReportRemoval', () => {
132132
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_A_ID}`, buildMoneyRequestReport(REPORT_A_ID, {stateNum: CONST.REPORT.STATE_NUM.OPEN}));
133133
await waitForBatchedUpdates();
134134

135-
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnReportRemoval(reportID), {
135+
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnMoneyRequestReportRemoval(reportID), {
136136
initialProps: {reportID: REPORT_A_ID},
137137
});
138138

@@ -161,7 +161,7 @@ describe('useDismissOnReportRemoval', () => {
161161
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_A_ID}`, buildMoneyRequestReport(REPORT_A_ID, {stateNum: CONST.REPORT.STATE_NUM.OPEN}));
162162
await waitForBatchedUpdates();
163163

164-
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnReportRemoval(reportID), {
164+
const {rerender} = renderHook(({reportID}: {reportID: string}) => useDismissOnMoneyRequestReportRemoval(reportID), {
165165
initialProps: {reportID: REPORT_A_ID},
166166
});
167167

0 commit comments

Comments
 (0)