@@ -3,27 +3,41 @@ import {View} from 'react-native';
33import type { ValueOf } from 'type-fest' ;
44import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' ;
55import { useMemoizedLazyExpensifyIcons } from '@hooks/useLazyAsset' ;
6+ import useLocalize from '@hooks/useLocalize' ;
67import useTheme from '@hooks/useTheme' ;
78import useThemeStyles from '@hooks/useThemeStyles' ;
8- import { parseMessage } from '@libs/NextStepUtils' ;
9+ import { buildNextStepMessage , parseMessage } from '@libs/NextStepUtils' ;
910import variables from '@styles/variables' ;
1011import CONST from '@src/CONST' ;
12+ import type { ReportNextStep } from '@src/types/onyx/Report' ;
1113import type ReportNextStepDeprecated from '@src/types/onyx/ReportNextStepDeprecated' ;
1214import type IconAsset from '@src/types/utils/IconAsset' ;
1315import Icon from './Icon' ;
1416import RenderHTML from './RenderHTML' ;
1517
18+ /** Combined type that accepts either the new format or the deprecated format */
19+ type NextStepData = ReportNextStep | ReportNextStepDeprecated ;
20+
1621type MoneyReportHeaderStatusBarProps = {
17- /** The next step for the report (deprecated old format ) */
18- nextStep : ReportNextStepDeprecated | undefined ;
22+ /** The next step for the report (supports both new and deprecated formats ) */
23+ nextStep : NextStepData | undefined ;
1924} ;
2025
2126type IconName = ValueOf < typeof CONST . NEXT_STEP . ICONS > ;
2227type IconMap = Record < IconName , IconAsset > ;
2328
29+ /**
30+ * Type guard to check if the next step is in the deprecated format (has message array)
31+ * We prioritize the old format first for backwards compatibility during migration.
32+ */
33+ function isDeprecatedFormatNextStep ( step : NextStepData ) : step is ReportNextStepDeprecated {
34+ return 'message' in step && Array . isArray ( step . message ) && step . message . length > 0 ;
35+ }
36+
2437function MoneyReportHeaderStatusBar ( { nextStep} : MoneyReportHeaderStatusBarProps ) {
2538 const styles = useThemeStyles ( ) ;
2639 const theme = useTheme ( ) ;
40+ const { translate} = useLocalize ( ) ;
2741 const icons = useMemoizedLazyExpensifyIcons ( [ 'Hourglass' , 'Checkmark' , 'Stopwatch' , 'DotIndicator' ] ) ;
2842 const iconMap : IconMap = useMemo (
2943 ( ) => ( {
@@ -35,11 +49,28 @@ function MoneyReportHeaderStatusBar({nextStep}: MoneyReportHeaderStatusBarProps)
3549 [ icons ] ,
3650 ) ;
3751 const currentUserPersonalDetails = useCurrentUserPersonalDetails ( ) ;
52+ const currentUserAccountID = currentUserPersonalDetails . accountID ;
3853 const currentUserEmail = currentUserPersonalDetails . login ?? '' ;
54+
3955 const messageContent = useMemo ( ( ) => {
40- const messageArray = nextStep ?. message ;
41- return parseMessage ( messageArray , currentUserEmail ) ;
42- } , [ nextStep ?. message , currentUserEmail ] ) ;
56+ if ( ! nextStep ) {
57+ return '' ;
58+ }
59+
60+ // Handle old/deprecated format first (with message array) for backwards compatibility
61+ if ( isDeprecatedFormatNextStep ( nextStep ) ) {
62+ return parseMessage ( nextStep . message , currentUserEmail ) ;
63+ }
64+
65+ // Fall back to new format (with messageKey)
66+ if ( 'messageKey' in nextStep && nextStep . messageKey ) {
67+ return buildNextStepMessage ( nextStep , translate , currentUserAccountID ) ;
68+ }
69+
70+ return '' ;
71+ } , [ nextStep , translate , currentUserAccountID , currentUserEmail ] ) ;
72+
73+ const iconFill = nextStep ?. iconFill ?? theme . icon ;
4374
4475 return (
4576 < View style = { [ styles . dFlex , styles . flexRow , styles . alignItemsCenter , styles . overflowHidden , styles . w100 , styles . headerStatusBarContainer ] } >
@@ -48,7 +79,7 @@ function MoneyReportHeaderStatusBar({nextStep}: MoneyReportHeaderStatusBarProps)
4879 src = { ( nextStep ?. icon && iconMap ?. [ nextStep . icon ] ) ?? icons . Hourglass }
4980 height = { variables . iconSizeSmall }
5081 width = { variables . iconSizeSmall }
51- fill = { nextStep ?. iconFill ?? theme . icon }
82+ fill = { iconFill }
5283 />
5384 </ View >
5485 < View style = { [ styles . dFlex , styles . flexRow , styles . flexShrink1 ] } >
0 commit comments