@@ -28,6 +28,7 @@ import useHandleSelectionMode from '@hooks/useHandleSelectionMode';
2828import { useMemoizedLazyExpensifyIcons } from '@hooks/useLazyAsset' ;
2929import useLocalize from '@hooks/useLocalize' ;
3030import useMobileSelectionMode from '@hooks/useMobileSelectionMode' ;
31+ import useNetwork from '@hooks/useNetwork' ;
3132import useOnyx from '@hooks/useOnyx' ;
3233import useReportIsArchived from '@hooks/useReportIsArchived' ;
3334import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
@@ -154,6 +155,7 @@ function MoneyRequestReportTransactionList({
154155 const [ isModalVisible , setIsModalVisible ] = useState ( false ) ;
155156 const [ selectedTransactionID , setSelectedTransactionID ] = useState < string > ( '' ) ;
156157 const { reportPendingAction} = getReportOfflinePendingActionAndErrors ( report ) ;
158+ const { isOffline} = useNetwork ( ) ;
157159
158160 const isTaxEnabled = isPolicyTaxEnabled ( policy ) ;
159161 const { totalDisplaySpend, nonReimbursableSpend, reimbursableSpend} = getMoneyRequestSpendBreakdown ( report ) ;
@@ -563,11 +565,36 @@ function MoneyRequestReportTransactionList({
563565 [ groupByOptions , reportLayoutGroupBy , styles , windowHeight , isInLandscapeMode ] ,
564566 ) ;
565567
568+ const isDesktopTableLayout = ! shouldUseNarrowLayout ;
569+
566570 const lastTransactionID = useMemo ( ( ) => {
567571 const allTransactions = shouldShowGroupedTransactions ? groupedTransactions . flatMap ( ( group ) => group . transactions ) : resolvedTransactions ;
568- const nonDeletedTransactions = allTransactions . filter ( ( t ) => ! isTransactionPendingDelete ( t ) ) ;
569- return nonDeletedTransactions . at ( - 1 ) ?. transactionID ;
570- } , [ shouldShowGroupedTransactions , groupedTransactions , resolvedTransactions ] ) ;
572+ const visibleTransactions = allTransactions . filter ( ( t ) => isOffline || ! isTransactionPendingDelete ( t ) ) ;
573+ return visibleTransactions . at ( - 1 ) ?. transactionID ;
574+ } , [ shouldShowGroupedTransactions , groupedTransactions , resolvedTransactions , isOffline ] ) ;
575+
576+ const renderTransactionItem = ( transaction : TransactionWithOptionalHighlight ) => (
577+ < MoneyRequestReportTransactionItem
578+ key = { transaction . transactionID }
579+ transaction = { transaction }
580+ shouldBeHighlighted = { highlightedTransactionIDs . has ( transaction . transactionID ) }
581+ columns = { columnsToShow }
582+ report = { report }
583+ policy = { policy }
584+ isSelectionModeEnabled = { isMobileSelectionModeEnabled }
585+ toggleTransaction = { toggleTransaction }
586+ isSelected = { isTransactionSelected ( transaction . transactionID ) }
587+ handleOnPress = { handleOnPress }
588+ handleLongPress = { handleLongPress }
589+ dateColumnSize = { dateColumnSize }
590+ amountColumnSize = { amountColumnSize }
591+ taxAmountColumnSize = { taxAmountColumnSize }
592+ scrollToNewTransaction = { transaction . transactionID === newTransactions ?. at ( 0 ) ?. transactionID ? scrollToNewTransaction : undefined }
593+ onArrowRightPress = { handleArrowRightPress }
594+ nonPersonalAndWorkspaceCards = { nonPersonalAndWorkspaceCards ?? { } }
595+ isLastItem = { ! showPendingExpensePlaceholder && transaction . transactionID === lastTransactionID }
596+ />
597+ ) ;
571598
572599 const transactionItems = shouldShowGroupedTransactions
573600 ? groupedTransactions . map ( ( group ) => {
@@ -577,12 +604,8 @@ function MoneyRequestReportTransactionList({
577604 isDisabled : false ,
578605 pendingAction : undefined ,
579606 } ;
580-
581607 return (
582- < View
583- key = { group . groupKey }
584- style = { ! shouldUseNarrowLayout && styles . gap2 }
585- >
608+ < View key = { group . groupKey } >
586609 < MoneyRequestReportGroupHeader
587610 group = { group }
588611 groupKey = { group . groupKey }
@@ -596,65 +619,17 @@ function MoneyRequestReportTransactionList({
596619 pendingAction = { selectionState . pendingAction }
597620 shouldUseNarrowLayout = { shouldUseNarrowLayout }
598621 />
599- { group . transactions . map ( ( transaction ) => {
600- const isLastItem = transaction . transactionID === lastTransactionID ;
601- return (
602- < MoneyRequestReportTransactionItem
603- key = { transaction . transactionID }
604- transaction = { transaction }
605- shouldBeHighlighted = { highlightedTransactionIDs . has ( transaction . transactionID ) }
606- columns = { columnsToShow }
607- report = { report }
608- policy = { policy }
609- isSelectionModeEnabled = { isMobileSelectionModeEnabled }
610- toggleTransaction = { toggleTransaction }
611- isSelected = { isTransactionSelected ( transaction . transactionID ) }
612- handleOnPress = { handleOnPress }
613- handleLongPress = { handleLongPress }
614- dateColumnSize = { dateColumnSize }
615- amountColumnSize = { amountColumnSize }
616- taxAmountColumnSize = { taxAmountColumnSize }
617- scrollToNewTransaction = { transaction . transactionID === newTransactions ?. at ( 0 ) ?. transactionID ? scrollToNewTransaction : undefined }
618- onArrowRightPress = { handleArrowRightPress }
619- nonPersonalAndWorkspaceCards = { nonPersonalAndWorkspaceCards ?? { } }
620- isLastItem = { isLastItem }
621- />
622- ) ;
623- } ) }
622+ { group . transactions . map ( ( transaction ) => renderTransactionItem ( transaction ) ) }
624623 </ View >
625624 ) ;
626625 } )
627- : resolvedTransactions . map ( ( transaction ) => {
628- const isLastItem = transaction . transactionID === lastTransactionID ;
629- return (
630- < MoneyRequestReportTransactionItem
631- key = { transaction . transactionID }
632- transaction = { transaction }
633- shouldBeHighlighted = { highlightedTransactionIDs . has ( transaction . transactionID ) }
634- columns = { columnsToShow }
635- report = { report }
636- policy = { policy }
637- isSelectionModeEnabled = { isMobileSelectionModeEnabled }
638- toggleTransaction = { toggleTransaction }
639- isSelected = { isTransactionSelected ( transaction . transactionID ) }
640- handleOnPress = { handleOnPress }
641- handleLongPress = { handleLongPress }
642- dateColumnSize = { dateColumnSize }
643- amountColumnSize = { amountColumnSize }
644- taxAmountColumnSize = { taxAmountColumnSize }
645- scrollToNewTransaction = { transaction . transactionID === newTransactions ?. at ( 0 ) ?. transactionID ? scrollToNewTransaction : undefined }
646- onArrowRightPress = { handleArrowRightPress }
647- nonPersonalAndWorkspaceCards = { nonPersonalAndWorkspaceCards ?? { } }
648- isLastItem = { isLastItem }
649- />
650- ) ;
651- } ) ;
626+ : resolvedTransactions . map ( ( transaction ) => renderTransactionItem ( transaction ) ) ;
652627
653628 const narrowListWrapper = shouldUseNarrowLayout ? [ styles . highlightBG , styles . searchTableTopRadius , styles . searchTableBottomRadius , styles . overflowHidden ] : undefined ;
654629
655630 const transactionListContent = (
656631 < View
657- style = { [ listHorizontalPadding , ! shouldUseNarrowLayout && styles . gap2 , shouldUseNarrowLayout ? styles . pb2 : styles . pb4 , ! shouldUseNarrowLayout && styles . mb2 ] }
632+ style = { [ listHorizontalPadding , shouldUseNarrowLayout ? styles . pb2 : styles . pb4 ] }
658633 onLayout = { onLayout }
659634 >
660635 { narrowListWrapper ? < View style = { narrowListWrapper } > { transactionItems } </ View > : transactionItems }
@@ -673,8 +648,27 @@ function MoneyRequestReportTransactionList({
673648
674649 const tableHeaderContent = (
675650 < OfflineWithFeedback pendingAction = { reportPendingAction } >
676- < View style = { [ styles . dFlex , styles . flexRow , styles . pl5 , styles . pr16 , styles . alignItemsCenter ] } >
677- < View style = { [ styles . dFlex , styles . flexRow , styles . pv2 , styles . pr4 , StyleUtils . getPaddingLeft ( variables . w12 ) ] } >
651+ < View
652+ style = { [
653+ styles . dFlex ,
654+ styles . flexRow ,
655+ ! isDesktopTableLayout && styles . pl5 ,
656+ isDesktopTableLayout ? styles . pr11 : styles . pr16 ,
657+ styles . alignItemsCenter ,
658+ isDesktopTableLayout && [ styles . highlightBG , styles . searchTableTopRadius , styles . mh5 , styles . borderBottom ] ,
659+ ] }
660+ >
661+ < View
662+ style = { [
663+ styles . dFlex ,
664+ styles . flexRow ,
665+ styles . alignItemsCenter ,
666+ styles . pv2 ,
667+ ! isDesktopTableLayout && styles . pr4 ,
668+ StyleUtils . getPaddingLeft ( variables . w12 ) ,
669+ isDesktopTableLayout && { minHeight : variables . tableGroupRowHeight } ,
670+ ] }
671+ >
678672 < Checkbox
679673 onPress = { ( ) => {
680674 if ( selectedTransactionIDs . length !== 0 ) {
@@ -686,14 +680,17 @@ function MoneyRequestReportTransactionList({
686680 accessibilityLabel = { translate ( 'accessibilityHints.selectAllTransactions' ) }
687681 isIndeterminate = { selectedTransactionIDs . length > 0 && selectedTransactionIDs . length !== transactionsWithoutPendingDelete . length }
688682 isChecked = { selectedTransactionIDs . length > 0 && selectedTransactionIDs . length === transactionsWithoutPendingDelete . length }
683+ containerStyle = { isDesktopTableLayout && styles . m0 }
684+ style = { isDesktopTableLayout && styles . mr3 }
689685 />
690- { isMediumScreenWidth && ! shouldScrollHorizontally && < Text style = { [ styles . textStrong , styles . ph3 ] } > { translate ( 'workspace.people.selectAll' ) } </ Text > }
686+ { isMediumScreenWidth && ! shouldScrollHorizontally && < Text style = { [ styles . labelStrong ] } > { translate ( 'workspace.people.selectAll' ) } </ Text > }
691687 </ View >
692688 { ( ! isMediumScreenWidth || shouldScrollHorizontally ) && (
693689 < MoneyRequestReportTableHeader
694690 shouldShowSorting
695691 sortBy = { sortBy }
696692 sortOrder = { sortOrder }
693+ shouldRemoveTotalColumnFlex
697694 columns = { columnsToShow }
698695 dateColumnSize = { dateColumnSize }
699696 amountColumnSize = { amountColumnSize }
0 commit comments