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
34 changes: 0 additions & 34 deletions src/components/PromotedActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {getPinMenuItem, getShareMenuItem} from '@libs/HeaderUtils';
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
import Navigation from '@libs/Navigation/Navigation';
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';
import type {ThreeDotsMenuItem} from './HeaderWithBackButton/types';
Expand All @@ -28,15 +25,6 @@ type PromotedActionsType = Record<BasePromotedActions, (report: OnyxReport) => P
[CONST.PROMOTED_ACTIONS.SHARE]: (report: OnyxReport, backTo?: string) => PromotedAction;
} & {
[CONST.PROMOTED_ACTIONS.MESSAGE]: (params: {reportID?: string; accountID?: number; login?: string}) => PromotedAction;
} & {
[CONST.PROMOTED_ACTIONS.HOLD]: (params: {
isTextHold: boolean;
reportAction: ReportAction | undefined;
reportID?: string;
isDelegateAccessRestricted: boolean;
setIsNoDelegateAccessMenuVisible: (isVisible: boolean) => void;
currentSearchHash?: number;
}) => PromotedAction;
};

const PromotedActions = {
Expand Down Expand Up @@ -77,28 +65,6 @@ const PromotedActions = {
}
},
}),
hold: ({isTextHold, reportAction, isDelegateAccessRestricted, setIsNoDelegateAccessMenuVisible, currentSearchHash}) => ({
key: CONST.PROMOTED_ACTIONS.HOLD,
icon: Expensicons.Stopwatch,
translationKey: `iou.${isTextHold ? 'hold' : 'unhold'}`,
onSelected: () => {
if (isDelegateAccessRestricted) {
setIsNoDelegateAccessMenuVisible(true); // Show the menu
return;
}

if (!isTextHold) {
Navigation.goBack();
}

if (!isSearchTopmostFullScreenRoute()) {
changeMoneyRequestHoldStatus(reportAction);
return;
}

changeMoneyRequestHoldStatus(reportAction, currentSearchHash);
},
}),
} satisfies PromotedActionsType;

type PromotedActionsBarProps = {
Expand Down
6 changes: 3 additions & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4042,7 +4042,7 @@ function canHoldUnholdReportAction(reportAction: OnyxInputOrEntry<ReportAction>)
return {canHoldRequest, canUnholdRequest};
}

const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>, searchHash?: number): void => {
const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>): void => {
if (!isMoneyRequestAction(reportAction)) {
return;
}
Expand All @@ -4065,10 +4065,10 @@ const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>, sea
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${moneyRequestReport.policyID}`] ?? null;

if (isOnHold) {
unholdRequest(transactionID, reportAction.childReportID, searchHash);
unholdRequest(transactionID, reportAction.childReportID);
} else {
const activeRoute = encodeURIComponent(Navigation.getActiveRoute());
Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute, searchHash));
Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute));
}
};

Expand Down
30 changes: 1 addition & 29 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10672,7 +10672,7 @@ function putOnHold(transactionID: string, comment: string, reportID: string, sea
/**
* Remove expense from HOLD
*/
function unholdRequest(transactionID: string, reportID: string, searchHash?: number) {
function unholdRequest(transactionID: string, reportID: string) {
const createdReportAction = buildOptimisticUnHoldReportAction();
const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`];
const transaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
Expand Down Expand Up @@ -10768,34 +10768,6 @@ function unholdRequest(transactionID: string, reportID: string, searchHash?: num
},
];

// If we are un-holding from the search page, we optimistically update the snapshot data that search uses so that it is kept in sync
if (searchHash) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`,
value: {
data: {
[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: {
canHold: true,
canUnhold: false,
},
},
} as Record<string, Record<string, Partial<SearchTransaction>>>,
});
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`,
value: {
data: {
[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: {
canHold: false,
canUnhold: true,
},
},
} as Record<string, Record<string, Partial<SearchTransaction>>>,
});
}

API.write(
'UnHoldRequest',
{
Expand Down
Loading
Loading