diff --git a/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx b/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx index 149688f059..971b7224a5 100644 --- a/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx +++ b/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx @@ -3,6 +3,7 @@ import { APPLICATION_LIST_TABS, } from 'benefit/handler/constants'; import FrontPageProvider from 'benefit/handler/context/FrontPageProvider'; +import { Application } from 'benefit/handler/types/application'; import { APPLICATION_STATUSES, BATCH_STATUSES } from 'benefit-shared/constants'; import { ApplicationListItemData } from 'benefit-shared/types/application'; import { LoadingSpinner, Tabs } from 'hds-react'; @@ -34,11 +35,20 @@ const isBatchStatusHandlingComplete = (batchStatus: BATCH_STATUSES): boolean => BATCH_STATUSES.REJECTED_BY_TALPA, ].includes(batchStatus); -const isAcceptedOrRejected = (status: APPLICATION_STATUSES): boolean => +export const isAcceptedOrRejected = (status: APPLICATION_STATUSES): boolean => [APPLICATION_STATUSES.ACCEPTED, APPLICATION_STATUSES.REJECTED].includes( status ); +export const isInPayment = ( + application: ApplicationListItemData | Application +): boolean => + [APPLICATION_STATUSES.ACCEPTED].includes(application.status) && + !isString(application.batch) && + [BATCH_STATUSES.DECIDED_ACCEPTED, BATCH_STATUSES.REJECTED_BY_TALPA].includes( + application?.batch?.status + ); + const HandlerIndex: React.FC = ({ layoutBackgroundColor, list = [], @@ -67,7 +77,10 @@ const HandlerIndex: React.FC = ({ ).length; const getTabCountInstalments = (): number => - list.filter((app: ApplicationListItemData) => app.pendingInstalment).length; + list.filter( + (app: ApplicationListItemData) => + app.pendingInstalment && isInPayment(app) + ).length; const getTabCountInPayment = (): number => list.filter( @@ -135,14 +148,6 @@ const HandlerIndex: React.FC = ({ const updateTabToUrl = (tabNumber: APPLICATION_LIST_TABS): void => window.history.pushState({ tab }, '', `/?tab=${tabNumber}`); - const isInPayment = (application: ApplicationListItemData): boolean => - [APPLICATION_STATUSES.ACCEPTED].includes(application.status) && - !isString(application.batch) && - [ - BATCH_STATUSES.DECIDED_ACCEPTED, - BATCH_STATUSES.REJECTED_BY_TALPA, - ].includes(application?.batch?.status); - return ( <$BackgroundWrapper backgroundColor={layoutBackgroundColor}> @@ -287,7 +292,9 @@ const HandlerIndex: React.FC = ({ app.pendingInstalment)} + list={list.filter( + (app) => app.pendingInstalment && isInPayment(app) + )} heading={t(`${translationBase}.instalments`)} /> diff --git a/frontend/benefit/handler/src/components/applicationReview/handlingView/DecisionCalculationAccordion.tsx b/frontend/benefit/handler/src/components/applicationReview/handlingView/DecisionCalculationAccordion.tsx index ab7aac6581..65f8f4b014 100644 --- a/frontend/benefit/handler/src/components/applicationReview/handlingView/DecisionCalculationAccordion.tsx +++ b/frontend/benefit/handler/src/components/applicationReview/handlingView/DecisionCalculationAccordion.tsx @@ -27,6 +27,7 @@ import { formatFloatToCurrency } from 'shared/utils/string.utils'; import { useTheme } from 'styled-components'; import { renderInstalmentTagPerStatus } from '../../applicationList/ApplicationListForInstalments'; +import { isInPayment } from '../../applicationList/HandlerIndex'; import { $CalculatorTableHeader, $CalculatorTableRow, @@ -158,7 +159,7 @@ const DecisionCalculationAccordion: React.FC = ({ data }) => { - {data.pendingInstalment && ( + {data.pendingInstalment && isInPayment(data) && ( <$DecisionCalculatorAccordion> <$DecisionCalculatorAccordionIconContainer aria-hidden="true">