Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/components/PromotedActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {changeMoneyRequestHoldStatus} from '@libs/ReportUtils';
import {joinRoom, navigateToAndOpenReport, navigateToAndOpenReportWithAccountIDs} from '@userActions/Report';
import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import type {ReportAction} from '@src/types/onyx';
import type OnyxReport from '@src/types/onyx/Report';
import Button from './Button';
Expand Down Expand Up @@ -77,7 +76,7 @@ const PromotedActions = {
}
},
}),
hold: ({isTextHold, reportAction, reportID, isDelegateAccessRestricted, setIsNoDelegateAccessMenuVisible, currentSearchHash}) => ({
hold: ({isTextHold, reportAction, isDelegateAccessRestricted, setIsNoDelegateAccessMenuVisible, currentSearchHash}) => ({
key: CONST.PROMOTED_ACTIONS.HOLD,
icon: Expensicons.Stopwatch,
text: translateLocal(`iou.${isTextHold ? 'hold' : 'unhold'}`),
Expand All @@ -90,14 +89,13 @@ const PromotedActions = {
if (!isTextHold) {
Navigation.goBack();
}
const targetedReportID = reportID ?? reportAction?.childReportID ?? '';

if (!isSearchTopmostFullScreenRoute() && isTextHold) {
changeMoneyRequestHoldStatus(reportAction, ROUTES.REPORT_WITH_ID.getRoute(targetedReportID));
changeMoneyRequestHoldStatus(reportAction);
return;
}

changeMoneyRequestHoldStatus(reportAction, ROUTES.SEARCH_REPORT.getRoute({reportID: targetedReportID}), currentSearchHash);
changeMoneyRequestHoldStatus(reportAction, currentSearchHash);
},
}),
} satisfies PromotedActionsType;
Expand Down
9 changes: 3 additions & 6 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3722,7 +3722,7 @@ function canHoldUnholdReportAction(reportAction: OnyxInputOrEntry<ReportAction>)
return {canHoldRequest, canUnholdRequest};
}

const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>, backTo?: string, searchHash?: number): void => {
const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>, searchHash?: number): void => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>, searchHash?: number): void => {
const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>, searchHash: number | undefined): void => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor

@hungvu193 hungvu193 Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is somethings we discussed internaly:


TL;DR:

When you see a failing lint rule for the default values, make sure the following is done:

- For numeric values, make sure you default to CONST.DEFAULT_NUMBER_ID instead of -1 or 0
For string values:
- You must remove the default fallback
- If the function you're passing this value to has this param specified as a non-nullable string:
- Change this parameter type to param: string | undefined, not param?: string
- Alter the function logic to handle the case when the param is passed as undefined. 
In many cases, it will mean adding an early return.
A good reference PR can be this: https://github.com/Expensify/App/pull/54297

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No @hungvu193 this is a different case. We intentionally made searchHash to be an optional param because we use the function for both search and non-search case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see :) my bad

if (!isMoneyRequestAction(reportAction)) {
return;
}
Expand All @@ -3747,11 +3747,8 @@ const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>, bac
if (isOnHold) {
unholdRequest(transactionID, reportAction.childReportID, searchHash);
} else {
const activeRoute = encodeURIComponent(Navigation.getActiveRouteWithoutParams());
Navigation.navigate(
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, backTo || activeRoute, searchHash),
);
const activeRoute = encodeURIComponent(Navigation.getActiveRoute());
Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute, searchHash));
}
};

Expand Down
Loading