@@ -2,7 +2,6 @@ import {useFocusEffect} from '@react-navigation/native';
22import isEmpty from 'lodash/isEmpty' ;
33import React , { memo , useCallback , useMemo , useState } from 'react' ;
44import { View } from 'react-native' ;
5- import Animated , { FadeIn , FadeOut } from 'react-native-reanimated' ;
65import type { TupleToUnion } from 'type-fest' ;
76import Checkbox from '@components/Checkbox' ;
87import * as Expensicons from '@components/Icon/Expensicons' ;
@@ -34,6 +33,7 @@ import NAVIGATORS from '@src/NAVIGATORS';
3433import ROUTES from '@src/ROUTES' ;
3534import type * as OnyxTypes from '@src/types/onyx' ;
3635import MoneyRequestReportTableHeader from './MoneyRequestReportTableHeader' ;
36+ import MoneyRequestReportTotalSpend from './MoneyRequestReportTotalSpend' ;
3737import MoneyRequestReportTransactionItem from './MoneyRequestReportTransactionItem' ;
3838import SearchMoneyRequestReportEmptyState from './SearchMoneyRequestReportEmptyState' ;
3939
@@ -110,10 +110,9 @@ function MoneyRequestReportTransactionList({
110110 const shouldShowBreakdown = ! ! nonReimbursableSpend && ! ! reimbursableSpend ;
111111 const transactionsWithoutPendingDelete = useMemo ( ( ) => transactions . filter ( ( t ) => ! isTransactionPendingDelete ( t ) ) , [ transactions ] ) ;
112112
113- const pendingActionsOpacity = useMemo ( ( ) => {
114- const pendingAction = transactions . some ( getTransactionPendingAction ) ;
115- return pendingAction && styles . opacitySemiTransparent ;
116- } , [ styles . opacitySemiTransparent , transactions ] ) ;
113+ const hasPendingAction = useMemo ( ( ) => {
114+ return transactions . some ( getTransactionPendingAction ) ;
115+ } , [ transactions ] ) ;
117116
118117 const { selectedTransactionIDs, setSelectedTransactions, clearSelectedTransactions} = useSearchContext ( ) ;
119118 const isMobileSelectionModeEnabled = useMobileSelectionMode ( ) ;
@@ -223,7 +222,19 @@ function MoneyRequestReportTransactionList({
223222 const listHorizontalPadding = styles . ph5 ;
224223
225224 if ( isEmptyTransactions ) {
226- return < SearchMoneyRequestReportEmptyState /> ;
225+ return (
226+ < >
227+ < SearchMoneyRequestReportEmptyState />
228+ < MoneyRequestReportTotalSpend
229+ hasComments = { hasComments }
230+ isLoadingReportActions = { ! ! isLoadingReportActions }
231+ isEmptyTransactions = { isEmptyTransactions }
232+ totalDisplaySpend = { totalDisplaySpend }
233+ report = { report }
234+ hasPendingAction = { hasPendingAction }
235+ />
236+ </ >
237+ ) ;
227238 }
228239
229240 return (
@@ -279,7 +290,8 @@ function MoneyRequestReportTransactionList({
279290 dateColumnSize = { dateColumnSize }
280291 amountColumnSize = { amountColumnSize }
281292 taxAmountColumnSize = { taxAmountColumnSize }
282- scrollToNewTransaction = { scrollToNewTransaction }
293+ // if we add few new transactions, then we need to scroll to the first one
294+ scrollToNewTransaction = { transaction . transactionID === newTransactions ?. at ( 0 ) ?. transactionID ? scrollToNewTransaction : undefined }
283295 />
284296 ) ;
285297 } ) }
@@ -307,6 +319,14 @@ function MoneyRequestReportTransactionList({
307319 ) ) }
308320 </ View >
309321 ) }
322+ < MoneyRequestReportTotalSpend
323+ hasComments = { hasComments }
324+ isLoadingReportActions = { ! ! isLoadingReportActions }
325+ isEmptyTransactions = { isEmptyTransactions }
326+ totalDisplaySpend = { totalDisplaySpend }
327+ report = { report }
328+ hasPendingAction = { hasPendingAction }
329+ />
310330 < Modal
311331 isVisible = { isModalVisible }
312332 type = { CONST . MODAL . MODAL_TYPE . BOTTOM_DOCKED }
@@ -325,24 +345,6 @@ function MoneyRequestReportTransactionList({
325345 } }
326346 />
327347 </ Modal >
328-
329- < View style = { [ styles . dFlex , styles . flexRow , listHorizontalPadding , styles . justifyContentBetween , styles . mb2 ] } >
330- < Animated . Text
331- style = { [ styles . textLabelSupporting ] }
332- entering = { hasComments ? undefined : FadeIn }
333- exiting = { FadeOut }
334- >
335- { hasComments || isLoadingReportActions ? translate ( 'common.comments' ) : '' }
336- </ Animated . Text >
337- { ! isEmptyTransactions && (
338- < View style = { [ styles . dFlex , styles . flexRow , styles . alignItemsCenter , styles . pr3 ] } >
339- < Text style = { [ styles . mr3 , styles . textLabelSupporting ] } > { translate ( 'common.total' ) } </ Text >
340- < Text style = { [ shouldUseNarrowLayout ? styles . mnw64p : styles . mnw100p , styles . textAlignRight , styles . textBold , pendingActionsOpacity ] } >
341- { convertToDisplayString ( totalDisplaySpend , report ?. currency ) }
342- </ Text >
343- </ View >
344- ) }
345- </ View >
346348 </ >
347349 ) ;
348350}
0 commit comments