Skip to content

Commit 5b07e2c

Browse files
chore: clean up create report quick action
1 parent 1236424 commit 5b07e2c

6 files changed

Lines changed: 7 additions & 73 deletions

File tree

src/libs/QuickActionUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ const getQuickActionTitle = (action: QuickActionName): TranslationPaths => {
8484
return 'quickAction.paySomeone';
8585
case CONST.QUICK_ACTIONS.ASSIGN_TASK:
8686
return 'quickAction.assignTask';
87-
case CONST.QUICK_ACTIONS.CREATE_REPORT:
88-
return 'quickAction.createReport';
8987
default:
9088
return '' as TranslationPaths;
9189
}

src/libs/actions/QuickActionNavigation.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
2-
import Navigation from '@libs/Navigation/Navigation';
31
import {generateReportID} from '@libs/ReportUtils';
42
import CONST from '@src/CONST';
5-
import ROUTES from '@src/ROUTES';
6-
import type {PersonalDetails} from '@src/types/onyx';
73
import type {QuickActionName} from '@src/types/onyx/QuickAction';
84
import type QuickAction from '@src/types/onyx/QuickAction';
95
import type {IOURequestType} from './IOU';
106
import {startMoneyRequest} from './IOU';
11-
import {createNewReport} from './Report';
127
import {startOutCreateTaskQuickAction} from './Task';
138

149
function getQuickActionRequestType(action: QuickActionName | undefined): IOURequestType | undefined {
@@ -30,13 +25,7 @@ function getQuickActionRequestType(action: QuickActionName | undefined): IOURequ
3025
return requestType;
3126
}
3227

33-
function navigateToQuickAction(
34-
isValidReport: boolean,
35-
quickAction: QuickAction,
36-
currentUserPersonalDetails: PersonalDetails,
37-
policyID: string | undefined,
38-
selectOption: (onSelected: () => void, shouldRestrictAction: boolean) => void,
39-
) {
28+
function navigateToQuickAction(isValidReport: boolean, quickAction: QuickAction, selectOption: (onSelected: () => void, shouldRestrictAction: boolean) => void) {
4029
const reportID = isValidReport && quickAction?.chatReportID ? quickAction?.chatReportID : generateReportID();
4130
const requestType = getQuickActionRequestType(quickAction?.action);
4231

@@ -63,18 +52,6 @@ function navigateToQuickAction(
6352
case CONST.QUICK_ACTIONS.TRACK_DISTANCE:
6453
selectOption(() => startMoneyRequest(CONST.IOU.TYPE.TRACK, reportID, requestType, true), false);
6554
break;
66-
case CONST.QUICK_ACTIONS.CREATE_REPORT:
67-
selectOption(() => {
68-
const optimisticReportID = createNewReport(currentUserPersonalDetails, policyID);
69-
Navigation.setNavigationActionToMicrotaskQueue(() => {
70-
Navigation.navigate(
71-
isSearchTopmostFullScreenRoute()
72-
? ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: optimisticReportID, backTo: Navigation.getActiveRoute()})
73-
: ROUTES.REPORT_WITH_ID.getRoute(optimisticReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()),
74-
);
75-
});
76-
}, true);
77-
break;
7855
default:
7956
}
8057
}

src/libs/actions/Report.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,15 +2752,6 @@ function buildNewReportOptimisticData(policy: OnyxEntry<Policy>, reportID: strin
27522752
key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${reportID}`,
27532753
value: optimisticNextStep,
27542754
},
2755-
{
2756-
onyxMethod: Onyx.METHOD.SET,
2757-
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
2758-
value: {
2759-
action: CONST.QUICK_ACTIONS.CREATE_REPORT,
2760-
chatReportID: parentReport?.reportID,
2761-
isFirstQuickAction: isEmptyObject(quickAction),
2762-
},
2763-
},
27642755
];
27652756

27662757
const failureData: OnyxUpdate[] = [
@@ -2774,11 +2765,6 @@ function buildNewReportOptimisticData(policy: OnyxEntry<Policy>, reportID: strin
27742765
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
27752766
value: {[reportActionID]: {errorFields: {createReport: getMicroSecondOnyxErrorWithTranslationKey('report.genericCreateReportFailureMessage')}}},
27762767
},
2777-
{
2778-
onyxMethod: Onyx.METHOD.SET,
2779-
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
2780-
value: quickAction ?? null,
2781-
},
27822768

27832769
{
27842770
onyxMethod: Onyx.METHOD.MERGE,

src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
189189
}, [isValidReport, quickActionAvatars, personalDetails, quickAction?.action]);
190190

191191
const quickActionSubtitle = useMemo(() => {
192-
if (quickAction?.action === CONST.QUICK_ACTIONS.CREATE_REPORT) {
193-
return quickActionPolicy?.name;
194-
}
195192
return !hideQABSubtitle ? (getReportName(quickActionReport) ?? translate('quickAction.updateDestination')) : '';
196193
// eslint-disable-next-line react-compiler/react-compiler
197194
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -336,7 +333,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
336333
showDelegateNoAccessModal();
337334
return;
338335
}
339-
navigateToQuickAction(isValidReport, quickAction, currentUserPersonalDetails, quickActionPolicy?.id, selectOption);
336+
navigateToQuickAction(isValidReport, quickAction, selectOption);
340337
});
341338
};
342339
return [
@@ -387,7 +384,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
387384
policyChatForActivePolicy,
388385
quickActionTitle,
389386
quickActionSubtitle,
390-
currentUserPersonalDetails,
391387
quickActionPolicy,
392388
quickActionReport,
393389
isValidReport,

tests/actions/ReportTest.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,20 +1585,6 @@ describe('actions/Report', () => {
15851585
});
15861586
});
15871587

1588-
await new Promise<void>((resolve) => {
1589-
const connection = Onyx.connect({
1590-
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
1591-
callback: (quickAction) => {
1592-
Onyx.disconnect(connection);
1593-
1594-
// Then the quickAction.action should be set to CREATE_REPORT
1595-
expect(quickAction?.action).toBe(CONST.QUICK_ACTIONS.CREATE_REPORT);
1596-
expect(quickAction?.chatReportID).toBe('1234');
1597-
resolve();
1598-
},
1599-
});
1600-
});
1601-
16021588
// When the request fails
16031589
mockFetchData.fail();
16041590
await mockFetchData.resume();

tests/unit/QuickActionNavigationTest.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {startMoneyRequest} from '@libs/actions/IOU';
22
import {navigateToQuickAction} from '@libs/actions/QuickActionNavigation';
3-
import {createNewReport} from '@libs/actions/Report';
43
import {startOutCreateTaskQuickAction} from '@libs/actions/Task';
54
import {generateReportID} from '@libs/ReportUtils';
65
import CONST from '@src/CONST';
@@ -22,7 +21,7 @@ describe('IOU Utils', () => {
2221

2322
it('should be navigated to Manual Submit Expense', () => {
2423
// When the quick action is REQUEST_MANUAL
25-
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.REQUEST_MANUAL, chatReportID: reportID}, {accountID: 1234}, undefined, (onSelected: () => void) => {
24+
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.REQUEST_MANUAL, chatReportID: reportID}, (onSelected: () => void) => {
2625
onSelected();
2726
});
2827
// Then we should start manual submit request flow
@@ -31,7 +30,7 @@ describe('IOU Utils', () => {
3130

3231
it('should be navigated to Scan receipt Split Expense', () => {
3332
// When the quick action is SPLIT_SCAN
34-
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.SPLIT_SCAN, chatReportID: reportID}, {accountID: 1234}, undefined, (onSelected: () => void) => {
33+
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.SPLIT_SCAN, chatReportID: reportID}, (onSelected: () => void) => {
3534
onSelected();
3635
});
3736
// Then we should start scan split request flow
@@ -40,7 +39,7 @@ describe('IOU Utils', () => {
4039

4140
it('should be navigated to Track distance Expense', () => {
4241
// When the quick action is TRACK_DISTANCE
43-
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.TRACK_DISTANCE, chatReportID: reportID}, {accountID: 1234}, undefined, (onSelected: () => void) => {
42+
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.TRACK_DISTANCE, chatReportID: reportID}, (onSelected: () => void) => {
4443
onSelected();
4544
});
4645
// Then we should start distance track request flow
@@ -49,7 +48,7 @@ describe('IOU Utils', () => {
4948

5049
it('should be navigated to Per Diem Expense', () => {
5150
// When the quick action is PER_DIEM
52-
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.PER_DIEM, chatReportID: reportID}, {accountID: 1234}, undefined, (onSelected: () => void) => {
51+
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.PER_DIEM, chatReportID: reportID}, (onSelected: () => void) => {
5352
onSelected();
5453
});
5554
// Then we should start per diem request flow
@@ -59,17 +58,9 @@ describe('IOU Utils', () => {
5958
});
6059

6160
describe('Non IOU quickActions test:', () => {
62-
const reportID = generateReportID();
63-
6461
describe('navigateToQuickAction', () => {
65-
it('creates new report for "createReport" quick action', () => {
66-
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.CREATE_REPORT, chatReportID: reportID}, {accountID: 1234}, undefined, (onSelected: () => void) => {
67-
onSelected();
68-
});
69-
expect(createNewReport).toHaveBeenCalled();
70-
});
7162
it('starts create task flow for "assignTask" quick action', () => {
72-
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.ASSIGN_TASK, targetAccountID: 123}, {accountID: 1234}, undefined, (onSelected: () => void) => {
63+
navigateToQuickAction(true, {action: CONST.QUICK_ACTIONS.ASSIGN_TASK, targetAccountID: 123}, (onSelected: () => void) => {
7364
onSelected();
7465
});
7566
expect(startOutCreateTaskQuickAction).toHaveBeenCalled();

0 commit comments

Comments
 (0)