From ad03aca8426f0ad13f65dc3b0fd75165a2a2a214 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 5 Jan 2024 15:39:53 +0700 Subject: [PATCH 01/11] fix: 33073 --- src/components/ReportActionItem/MoneyRequestAction.js | 5 ----- src/pages/home/report/ReportActionItem.js | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index e0a3152a41b4..d159998b2d57 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -34,9 +34,6 @@ const propTypes = { /** The ID of the associated request report */ requestReportID: PropTypes.string.isRequired, - /** Is this IOUACTION the most recent? */ - isMostRecentIOUReportAction: PropTypes.bool.isRequired, - /** Popover context menu anchor, used for showing context menu */ contextMenuAnchor: refPropTypes, @@ -81,7 +78,6 @@ function MoneyRequestAction({ action, chatReportID, requestReportID, - isMostRecentIOUReportAction, contextMenuAnchor, checkIfContextMenuActive, chatReport, @@ -123,7 +119,6 @@ function MoneyRequestAction({ !_.isEmpty(iouReport) && !_.isEmpty(reportActions) && chatReport.iouReportID && - isMostRecentIOUReportAction && action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && network.isOffline ) { diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 435c086d913f..20ddb127f48a 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -322,7 +322,7 @@ function ReportActionItem(props) { const iouReportID = originalMessage.IOUReportID ? originalMessage.IOUReportID.toString() : '0'; children = ( Date: Fri, 5 Jan 2024 15:51:29 +0700 Subject: [PATCH 02/11] remove most recent iou report action id --- .../ReportActionItem/MoneyRequestAction.js | 8 +------- src/pages/home/report/ReportActionItem.js | 5 ----- .../home/report/ReportActionItemParentAction.js | 1 - src/pages/home/report/ReportActionsList.js | 8 +------- .../home/report/ReportActionsListItemRenderer.js | 16 +--------------- src/pages/home/report/ReportActionsView.js | 4 ---- 6 files changed, 3 insertions(+), 39 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index d159998b2d57..46226969636e 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -115,13 +115,7 @@ function MoneyRequestAction({ let shouldShowPendingConversionMessage = false; const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); const isReversedTransaction = ReportActionsUtils.isReversedTransaction(action); - if ( - !_.isEmpty(iouReport) && - !_.isEmpty(reportActions) && - chatReport.iouReportID && - action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && - network.isOffline - ) { + if (!_.isEmpty(iouReport) && !_.isEmpty(reportActions) && chatReport.iouReportID && action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && network.isOffline) { shouldShowPendingConversionMessage = IOUUtils.isIOUReportPendingCurrencyConversion(iouReport); } diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 20ddb127f48a..4b5a43215ee5 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -88,9 +88,6 @@ const propTypes = { /** Should the comment have the appearance of being grouped with the previous comment? */ displayAsGroup: PropTypes.bool.isRequired, - /** Is this the most recent IOU Action? */ - isMostRecentIOUReportAction: PropTypes.bool.isRequired, - /** Should we display the new marker on top of the comment? */ shouldDisplayNewMarker: PropTypes.bool.isRequired, @@ -325,7 +322,6 @@ function ReportActionItem(props) { chatReportID={originalMessage.IOUReportID ? props.report.chatReportID : props.report.reportID} requestReportID={iouReportID} action={props.action} - isMostRecentIOUReportAction={props.isMostRecentIOUReportAction} isHovered={hovered} contextMenuAnchor={popoverAnchorRef} checkIfContextMenuActive={toggleContextMenuFromActiveReportAction} @@ -775,7 +771,6 @@ export default compose( (prevProps, nextProps) => prevProps.displayAsGroup === nextProps.displayAsGroup && prevProps.draftMessage === nextProps.draftMessage && - prevProps.isMostRecentIOUReportAction === nextProps.isMostRecentIOUReportAction && prevProps.shouldDisplayNewMarker === nextProps.shouldDisplayNewMarker && _.isEqual(prevProps.emojiReactions, nextProps.emojiReactions) && _.isEqual(prevProps.action, nextProps.action) && diff --git a/src/pages/home/report/ReportActionItemParentAction.js b/src/pages/home/report/ReportActionItemParentAction.js index c11200ccc4db..161c8048ab3d 100644 --- a/src/pages/home/report/ReportActionItemParentAction.js +++ b/src/pages/home/report/ReportActionItemParentAction.js @@ -70,7 +70,6 @@ function ReportActionItemParentAction(props) { report={props.report} action={parentReportAction} displayAsGroup={false} - isMostRecentIOUReportAction={false} shouldDisplayNewMarker={props.shouldDisplayNewMarker} index={0} /> diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index 2009dc9a102d..c7f48a38aeea 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -34,9 +34,6 @@ const propTypes = { /** Sorted actions prepared for display */ sortedReportActions: PropTypes.arrayOf(PropTypes.shape(reportActionPropTypes)).isRequired, - /** The ID of the most recent IOU report action connected with the shown report */ - mostRecentIOUReportActionID: PropTypes.string, - /** The report metadata loading states */ isLoadingInitialReportActions: PropTypes.bool, @@ -73,7 +70,6 @@ const propTypes = { const defaultProps = { onScroll: () => {}, - mostRecentIOUReportActionID: '', isLoadingInitialReportActions: false, isLoadingOlderReportActions: false, isLoadingNewerReportActions: false, @@ -128,7 +124,6 @@ function ReportActionsList({ sortedReportActions, windowHeight, onScroll, - mostRecentIOUReportActionID, isSmallScreenWidth, personalDetailsList, currentUserPersonalDetails, @@ -398,12 +393,11 @@ function ReportActionsList({ report={report} linkedReportActionID={linkedReportActionID} displayAsGroup={ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedReportActions, index)} - mostRecentIOUReportActionID={mostRecentIOUReportActionID} shouldHideThreadDividerLine={shouldHideThreadDividerLine} shouldDisplayNewMarker={shouldDisplayNewMarker(reportAction, index)} /> ), - [report, linkedReportActionID, sortedReportActions, mostRecentIOUReportActionID, shouldHideThreadDividerLine, shouldDisplayNewMarker], + [report, linkedReportActionID, sortedReportActions, shouldHideThreadDividerLine, shouldDisplayNewMarker], ); // Native mobile does not render updates flatlist the changes even though component did update called. diff --git a/src/pages/home/report/ReportActionsListItemRenderer.js b/src/pages/home/report/ReportActionsListItemRenderer.js index ba47e804de06..01f4bc66d59d 100644 --- a/src/pages/home/report/ReportActionsListItemRenderer.js +++ b/src/pages/home/report/ReportActionsListItemRenderer.js @@ -22,9 +22,6 @@ const propTypes = { /** Should the comment have the appearance of being grouped with the previous comment? */ displayAsGroup: PropTypes.bool.isRequired, - /** The ID of the most recent IOU report action connected with the shown report */ - mostRecentIOUReportActionID: PropTypes.string, - /** If the thread divider line should be hidden */ shouldHideThreadDividerLine: PropTypes.bool.isRequired, @@ -36,20 +33,10 @@ const propTypes = { }; const defaultProps = { - mostRecentIOUReportActionID: '', linkedReportActionID: '', }; -function ReportActionsListItemRenderer({ - reportAction, - index, - report, - displayAsGroup, - mostRecentIOUReportActionID, - shouldHideThreadDividerLine, - shouldDisplayNewMarker, - linkedReportActionID, -}) { +function ReportActionsListItemRenderer({reportAction, index, report, displayAsGroup, shouldHideThreadDividerLine, shouldDisplayNewMarker, linkedReportActionID}) { const shouldDisplayParentAction = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && ReportUtils.isChatThread(report) && @@ -77,7 +64,6 @@ function ReportActionsListItemRenderer({ reportAction.actionName, ) } - isMostRecentIOUReportAction={reportAction.reportActionID === mostRecentIOUReportActionID} index={index} /> ); diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 2758437a3962..ddcea7894251 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -14,7 +14,6 @@ import usePrevious from '@hooks/usePrevious'; import compose from '@libs/compose'; import getIsReportFullyVisible from '@libs/getIsReportFullyVisible'; import Performance from '@libs/Performance'; -import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import {isUserCreatedPolicyRoom} from '@libs/ReportUtils'; import {didUserLogInDuringSession} from '@libs/SessionUtils'; import {ReactionListContext} from '@pages/home/ReportScreenContext'; @@ -87,8 +86,6 @@ function ReportActionsView(props) { const didSubscribeToReportTypingEvents = useRef(false); const isFirstRender = useRef(true); const hasCachedActions = useInitialValue(() => _.size(props.reportActions) > 0); - const mostRecentIOUReportActionID = useInitialValue(() => ReportActionsUtils.getMostRecentIOURequestActionID(props.reportActions)); - const prevNetworkRef = useRef(props.network); const prevAuthTokenType = usePrevious(props.session.authTokenType); @@ -257,7 +254,6 @@ function ReportActionsView(props) { report={props.report} onLayout={recordTimeToMeasureItemLayout} sortedReportActions={props.reportActions} - mostRecentIOUReportActionID={mostRecentIOUReportActionID} loadOlderChats={loadOlderChats} loadNewerChats={loadNewerChats} isLoadingInitialReportActions={props.isLoadingInitialReportActions} From 43c38ba40b27b6f8450c4280f9cf6cd720640067 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 15 Jan 2024 14:02:07 +0700 Subject: [PATCH 03/11] only display pending message for foreign currency transaction --- src/components/ReportActionItem/MoneyRequestAction.js | 2 +- src/libs/IOUUtils.ts | 10 ++++++---- tests/unit/IOUUtilsTest.js | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index 46226969636e..d242dbe23e86 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -116,7 +116,7 @@ function MoneyRequestAction({ const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); const isReversedTransaction = ReportActionsUtils.isReversedTransaction(action); if (!_.isEmpty(iouReport) && !_.isEmpty(reportActions) && chatReport.iouReportID && action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && network.isOffline) { - shouldShowPendingConversionMessage = IOUUtils.isIOUReportPendingCurrencyConversion(iouReport); + shouldShowPendingConversionMessage = IOUUtils.isTransactionPendingCurrencyConversion(iouReport, (action && action.originalMessage && action.originalMessage.IOUTransactionID) || 0); } return isDeletedParentAction || isReversedTransaction ? ( diff --git a/src/libs/IOUUtils.ts b/src/libs/IOUUtils.ts index 11dd0f5badda..aab9aac2391d 100644 --- a/src/libs/IOUUtils.ts +++ b/src/libs/IOUUtils.ts @@ -110,12 +110,14 @@ function updateIOUOwnerAndTotal(iouReport: OnyxEntry, actorAccountID: nu } /** - * Returns whether or not an IOU report contains money requests in a different currency + * Returns whether or not a transaction of IOU report contains money requests in a different currency * that are either created or cancelled offline, and thus haven't been converted to the report's currency yet */ -function isIOUReportPendingCurrencyConversion(iouReport: Report): boolean { +function isTransactionPendingCurrencyConversion(iouReport: Report, transactionID: string): boolean { const reportTransactions: Transaction[] = TransactionUtils.getAllReportTransactions(iouReport.reportID); - const pendingRequestsInDifferentCurrency = reportTransactions.filter((transaction) => transaction.pendingAction && TransactionUtils.getCurrency(transaction) !== iouReport.currency); + const pendingRequestsInDifferentCurrency = reportTransactions.filter( + (transaction) => transaction.pendingAction && transaction.transactionID === transactionID && TransactionUtils.getCurrency(transaction) !== iouReport.currency, + ); return pendingRequestsInDifferentCurrency.length > 0; } @@ -127,4 +129,4 @@ function isValidMoneyRequestType(iouType: string): boolean { return moneyRequestType.includes(iouType); } -export {calculateAmount, updateIOUOwnerAndTotal, isIOUReportPendingCurrencyConversion, isValidMoneyRequestType, navigateToStartMoneyRequestStep, navigateToStartStepIfScanFileCannotBeRead}; +export {calculateAmount, updateIOUOwnerAndTotal, isTransactionPendingCurrencyConversion, isValidMoneyRequestType, navigateToStartMoneyRequestStep, navigateToStartStepIfScanFileCannotBeRead}; diff --git a/tests/unit/IOUUtilsTest.js b/tests/unit/IOUUtilsTest.js index ac04b74a0ca5..7f239d9bb576 100644 --- a/tests/unit/IOUUtilsTest.js +++ b/tests/unit/IOUUtilsTest.js @@ -17,7 +17,7 @@ function initCurrencyList() { } describe('IOUUtils', () => { - describe('isIOUReportPendingCurrencyConversion', () => { + describe('isTransactionPendingCurrencyConversion', () => { beforeAll(() => { Onyx.init({ keys: ONYXKEYS, @@ -34,7 +34,7 @@ describe('IOUUtils', () => { [`${ONYXKEYS.COLLECTION.TRANSACTION}${aedPendingTransaction.transactionID}`]: aedPendingTransaction, }).then(() => { // We requested money offline in a different currency, we don't know the total of the iouReport until we're back online - expect(IOUUtils.isIOUReportPendingCurrencyConversion(iouReport)).toBe(true); + expect(IOUUtils.isTransactionPendingCurrencyConversion(iouReport, aedPendingTransaction.transactionID)).toBe(true); }); }); @@ -54,7 +54,7 @@ describe('IOUUtils', () => { }, }).then(() => { // We requested money online in a different currency, we know the iouReport total and there's no need to show the pending conversion message - expect(IOUUtils.isIOUReportPendingCurrencyConversion(iouReport)).toBe(false); + expect(IOUUtils.isTransactionPendingCurrencyConversion(iouReport, aedPendingTransaction.transactionID)).toBe(false); }); }); }); From ea5c3a2b6c180a94601b4d2408614db0e44dd5d4 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 15 Jan 2024 23:03:49 +0700 Subject: [PATCH 04/11] fallback string instead of number --- src/components/ReportActionItem/MoneyRequestAction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index d242dbe23e86..241b3e32447a 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -116,7 +116,7 @@ function MoneyRequestAction({ const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); const isReversedTransaction = ReportActionsUtils.isReversedTransaction(action); if (!_.isEmpty(iouReport) && !_.isEmpty(reportActions) && chatReport.iouReportID && action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && network.isOffline) { - shouldShowPendingConversionMessage = IOUUtils.isTransactionPendingCurrencyConversion(iouReport, (action && action.originalMessage && action.originalMessage.IOUTransactionID) || 0); + shouldShowPendingConversionMessage = IOUUtils.isTransactionPendingCurrencyConversion(iouReport, (action && action.originalMessage && action.originalMessage.IOUTransactionID) || '0'); } return isDeletedParentAction || isReversedTransaction ? ( From bd4d978f94884911335142ff990235dc57410153 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 19 Jan 2024 14:57:27 +0700 Subject: [PATCH 05/11] Revert "fallback string instead of number" This reverts commit ea5c3a2b6c180a94601b4d2408614db0e44dd5d4. --- src/components/ReportActionItem/MoneyRequestAction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index 241b3e32447a..d242dbe23e86 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -116,7 +116,7 @@ function MoneyRequestAction({ const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); const isReversedTransaction = ReportActionsUtils.isReversedTransaction(action); if (!_.isEmpty(iouReport) && !_.isEmpty(reportActions) && chatReport.iouReportID && action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && network.isOffline) { - shouldShowPendingConversionMessage = IOUUtils.isTransactionPendingCurrencyConversion(iouReport, (action && action.originalMessage && action.originalMessage.IOUTransactionID) || '0'); + shouldShowPendingConversionMessage = IOUUtils.isTransactionPendingCurrencyConversion(iouReport, (action && action.originalMessage && action.originalMessage.IOUTransactionID) || 0); } return isDeletedParentAction || isReversedTransaction ? ( From 4cfb299c7e87b596678843c6630b4a93afa1b95b Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 19 Jan 2024 14:57:44 +0700 Subject: [PATCH 06/11] Revert "only display pending message for foreign currency transaction" This reverts commit 43c38ba40b27b6f8450c4280f9cf6cd720640067. --- src/components/ReportActionItem/MoneyRequestAction.js | 2 +- src/libs/IOUUtils.ts | 10 ++++------ tests/unit/IOUUtilsTest.js | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index d242dbe23e86..46226969636e 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -116,7 +116,7 @@ function MoneyRequestAction({ const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); const isReversedTransaction = ReportActionsUtils.isReversedTransaction(action); if (!_.isEmpty(iouReport) && !_.isEmpty(reportActions) && chatReport.iouReportID && action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && network.isOffline) { - shouldShowPendingConversionMessage = IOUUtils.isTransactionPendingCurrencyConversion(iouReport, (action && action.originalMessage && action.originalMessage.IOUTransactionID) || 0); + shouldShowPendingConversionMessage = IOUUtils.isIOUReportPendingCurrencyConversion(iouReport); } return isDeletedParentAction || isReversedTransaction ? ( diff --git a/src/libs/IOUUtils.ts b/src/libs/IOUUtils.ts index aab9aac2391d..11dd0f5badda 100644 --- a/src/libs/IOUUtils.ts +++ b/src/libs/IOUUtils.ts @@ -110,14 +110,12 @@ function updateIOUOwnerAndTotal(iouReport: OnyxEntry, actorAccountID: nu } /** - * Returns whether or not a transaction of IOU report contains money requests in a different currency + * Returns whether or not an IOU report contains money requests in a different currency * that are either created or cancelled offline, and thus haven't been converted to the report's currency yet */ -function isTransactionPendingCurrencyConversion(iouReport: Report, transactionID: string): boolean { +function isIOUReportPendingCurrencyConversion(iouReport: Report): boolean { const reportTransactions: Transaction[] = TransactionUtils.getAllReportTransactions(iouReport.reportID); - const pendingRequestsInDifferentCurrency = reportTransactions.filter( - (transaction) => transaction.pendingAction && transaction.transactionID === transactionID && TransactionUtils.getCurrency(transaction) !== iouReport.currency, - ); + const pendingRequestsInDifferentCurrency = reportTransactions.filter((transaction) => transaction.pendingAction && TransactionUtils.getCurrency(transaction) !== iouReport.currency); return pendingRequestsInDifferentCurrency.length > 0; } @@ -129,4 +127,4 @@ function isValidMoneyRequestType(iouType: string): boolean { return moneyRequestType.includes(iouType); } -export {calculateAmount, updateIOUOwnerAndTotal, isTransactionPendingCurrencyConversion, isValidMoneyRequestType, navigateToStartMoneyRequestStep, navigateToStartStepIfScanFileCannotBeRead}; +export {calculateAmount, updateIOUOwnerAndTotal, isIOUReportPendingCurrencyConversion, isValidMoneyRequestType, navigateToStartMoneyRequestStep, navigateToStartStepIfScanFileCannotBeRead}; diff --git a/tests/unit/IOUUtilsTest.js b/tests/unit/IOUUtilsTest.js index 7f239d9bb576..ac04b74a0ca5 100644 --- a/tests/unit/IOUUtilsTest.js +++ b/tests/unit/IOUUtilsTest.js @@ -17,7 +17,7 @@ function initCurrencyList() { } describe('IOUUtils', () => { - describe('isTransactionPendingCurrencyConversion', () => { + describe('isIOUReportPendingCurrencyConversion', () => { beforeAll(() => { Onyx.init({ keys: ONYXKEYS, @@ -34,7 +34,7 @@ describe('IOUUtils', () => { [`${ONYXKEYS.COLLECTION.TRANSACTION}${aedPendingTransaction.transactionID}`]: aedPendingTransaction, }).then(() => { // We requested money offline in a different currency, we don't know the total of the iouReport until we're back online - expect(IOUUtils.isTransactionPendingCurrencyConversion(iouReport, aedPendingTransaction.transactionID)).toBe(true); + expect(IOUUtils.isIOUReportPendingCurrencyConversion(iouReport)).toBe(true); }); }); @@ -54,7 +54,7 @@ describe('IOUUtils', () => { }, }).then(() => { // We requested money online in a different currency, we know the iouReport total and there's no need to show the pending conversion message - expect(IOUUtils.isTransactionPendingCurrencyConversion(iouReport, aedPendingTransaction.transactionID)).toBe(false); + expect(IOUUtils.isIOUReportPendingCurrencyConversion(iouReport)).toBe(false); }); }); }); From db3e96cc82c6467ef16d54c748a5dbb154b847c6 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 19 Jan 2024 14:57:57 +0700 Subject: [PATCH 07/11] Revert "remove most recent iou report action id" This reverts commit 964763547f578d20b5bb3d21120e0189b33b37ba. --- .../ReportActionItem/MoneyRequestAction.js | 8 +++++++- src/pages/home/report/ReportActionItem.js | 5 +++++ .../home/report/ReportActionItemParentAction.js | 1 + src/pages/home/report/ReportActionsList.js | 8 +++++++- .../home/report/ReportActionsListItemRenderer.js | 16 +++++++++++++++- src/pages/home/report/ReportActionsView.js | 4 ++++ 6 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index 46226969636e..d159998b2d57 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -115,7 +115,13 @@ function MoneyRequestAction({ let shouldShowPendingConversionMessage = false; const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); const isReversedTransaction = ReportActionsUtils.isReversedTransaction(action); - if (!_.isEmpty(iouReport) && !_.isEmpty(reportActions) && chatReport.iouReportID && action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && network.isOffline) { + if ( + !_.isEmpty(iouReport) && + !_.isEmpty(reportActions) && + chatReport.iouReportID && + action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && + network.isOffline + ) { shouldShowPendingConversionMessage = IOUUtils.isIOUReportPendingCurrencyConversion(iouReport); } diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 2f8e86de5cdb..55b294936f49 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -89,6 +89,9 @@ const propTypes = { /** Should the comment have the appearance of being grouped with the previous comment? */ displayAsGroup: PropTypes.bool.isRequired, + /** Is this the most recent IOU Action? */ + isMostRecentIOUReportAction: PropTypes.bool.isRequired, + /** Should we display the new marker on top of the comment? */ shouldDisplayNewMarker: PropTypes.bool.isRequired, @@ -346,6 +349,7 @@ function ReportActionItem(props) { chatReportID={originalMessage.IOUReportID ? props.report.chatReportID : props.report.reportID} requestReportID={iouReportID} action={props.action} + isMostRecentIOUReportAction={props.isMostRecentIOUReportAction} isHovered={hovered} contextMenuAnchor={popoverAnchorRef} checkIfContextMenuActive={toggleContextMenuFromActiveReportAction} @@ -819,6 +823,7 @@ export default compose( (prevProps, nextProps) => prevProps.displayAsGroup === nextProps.displayAsGroup && prevProps.draftMessage === nextProps.draftMessage && + prevProps.isMostRecentIOUReportAction === nextProps.isMostRecentIOUReportAction && prevProps.shouldDisplayNewMarker === nextProps.shouldDisplayNewMarker && _.isEqual(prevProps.emojiReactions, nextProps.emojiReactions) && _.isEqual(prevProps.action, nextProps.action) && diff --git a/src/pages/home/report/ReportActionItemParentAction.js b/src/pages/home/report/ReportActionItemParentAction.js index 7c9f08b35ce7..d1a294881eb9 100644 --- a/src/pages/home/report/ReportActionItemParentAction.js +++ b/src/pages/home/report/ReportActionItemParentAction.js @@ -73,6 +73,7 @@ function ReportActionItemParentAction(props) { report={props.report} action={parentReportAction} displayAsGroup={false} + isMostRecentIOUReportAction={false} shouldDisplayNewMarker={props.shouldDisplayNewMarker} index={props.index} /> diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index 635466219f2b..8d79e7af8dd4 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -34,6 +34,9 @@ const propTypes = { /** Sorted actions prepared for display */ sortedReportActions: PropTypes.arrayOf(PropTypes.shape(reportActionPropTypes)).isRequired, + /** The ID of the most recent IOU report action connected with the shown report */ + mostRecentIOUReportActionID: PropTypes.string, + /** The report metadata loading states */ isLoadingInitialReportActions: PropTypes.bool, @@ -70,6 +73,7 @@ const propTypes = { const defaultProps = { onScroll: () => {}, + mostRecentIOUReportActionID: '', isLoadingInitialReportActions: false, isLoadingOlderReportActions: false, isLoadingNewerReportActions: false, @@ -124,6 +128,7 @@ function ReportActionsList({ sortedReportActions, windowHeight, onScroll, + mostRecentIOUReportActionID, isSmallScreenWidth, personalDetailsList, currentUserPersonalDetails, @@ -410,11 +415,12 @@ function ReportActionsList({ report={report} linkedReportActionID={linkedReportActionID} displayAsGroup={ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedReportActions, index)} + mostRecentIOUReportActionID={mostRecentIOUReportActionID} shouldHideThreadDividerLine={shouldHideThreadDividerLine} shouldDisplayNewMarker={shouldDisplayNewMarker(reportAction, index)} /> ), - [report, linkedReportActionID, sortedReportActions, shouldHideThreadDividerLine, shouldDisplayNewMarker], + [report, linkedReportActionID, sortedReportActions, mostRecentIOUReportActionID, shouldHideThreadDividerLine, shouldDisplayNewMarker], ); // Native mobile does not render updates flatlist the changes even though component did update called. diff --git a/src/pages/home/report/ReportActionsListItemRenderer.js b/src/pages/home/report/ReportActionsListItemRenderer.js index 791a3f78c67b..a9ae2b4c73b9 100644 --- a/src/pages/home/report/ReportActionsListItemRenderer.js +++ b/src/pages/home/report/ReportActionsListItemRenderer.js @@ -22,6 +22,9 @@ const propTypes = { /** Should the comment have the appearance of being grouped with the previous comment? */ displayAsGroup: PropTypes.bool.isRequired, + /** The ID of the most recent IOU report action connected with the shown report */ + mostRecentIOUReportActionID: PropTypes.string, + /** If the thread divider line should be hidden */ shouldHideThreadDividerLine: PropTypes.bool.isRequired, @@ -33,10 +36,20 @@ const propTypes = { }; const defaultProps = { + mostRecentIOUReportActionID: '', linkedReportActionID: '', }; -function ReportActionsListItemRenderer({reportAction, index, report, displayAsGroup, shouldHideThreadDividerLine, shouldDisplayNewMarker, linkedReportActionID}) { +function ReportActionsListItemRenderer({ + reportAction, + index, + report, + displayAsGroup, + mostRecentIOUReportActionID, + shouldHideThreadDividerLine, + shouldDisplayNewMarker, + linkedReportActionID, +}) { const shouldDisplayParentAction = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && ReportUtils.isChatThread(report) && @@ -65,6 +78,7 @@ function ReportActionsListItemRenderer({reportAction, index, report, displayAsGr reportAction.actionName, ) } + isMostRecentIOUReportAction={reportAction.reportActionID === mostRecentIOUReportActionID} index={index} /> ); diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index ddcea7894251..2758437a3962 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -14,6 +14,7 @@ import usePrevious from '@hooks/usePrevious'; import compose from '@libs/compose'; import getIsReportFullyVisible from '@libs/getIsReportFullyVisible'; import Performance from '@libs/Performance'; +import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import {isUserCreatedPolicyRoom} from '@libs/ReportUtils'; import {didUserLogInDuringSession} from '@libs/SessionUtils'; import {ReactionListContext} from '@pages/home/ReportScreenContext'; @@ -86,6 +87,8 @@ function ReportActionsView(props) { const didSubscribeToReportTypingEvents = useRef(false); const isFirstRender = useRef(true); const hasCachedActions = useInitialValue(() => _.size(props.reportActions) > 0); + const mostRecentIOUReportActionID = useInitialValue(() => ReportActionsUtils.getMostRecentIOURequestActionID(props.reportActions)); + const prevNetworkRef = useRef(props.network); const prevAuthTokenType = usePrevious(props.session.authTokenType); @@ -254,6 +257,7 @@ function ReportActionsView(props) { report={props.report} onLayout={recordTimeToMeasureItemLayout} sortedReportActions={props.reportActions} + mostRecentIOUReportActionID={mostRecentIOUReportActionID} loadOlderChats={loadOlderChats} loadNewerChats={loadNewerChats} isLoadingInitialReportActions={props.isLoadingInitialReportActions} From 86a41083ee018b2409aefe02d87b3901e479be24 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 19 Jan 2024 14:58:05 +0700 Subject: [PATCH 08/11] Revert "fix: 33073" This reverts commit ad03aca8426f0ad13f65dc3b0fd75165a2a2a214. --- src/components/ReportActionItem/MoneyRequestAction.js | 5 +++++ src/pages/home/report/ReportActionItem.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index d159998b2d57..e0a3152a41b4 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -34,6 +34,9 @@ const propTypes = { /** The ID of the associated request report */ requestReportID: PropTypes.string.isRequired, + /** Is this IOUACTION the most recent? */ + isMostRecentIOUReportAction: PropTypes.bool.isRequired, + /** Popover context menu anchor, used for showing context menu */ contextMenuAnchor: refPropTypes, @@ -78,6 +81,7 @@ function MoneyRequestAction({ action, chatReportID, requestReportID, + isMostRecentIOUReportAction, contextMenuAnchor, checkIfContextMenuActive, chatReport, @@ -119,6 +123,7 @@ function MoneyRequestAction({ !_.isEmpty(iouReport) && !_.isEmpty(reportActions) && chatReport.iouReportID && + isMostRecentIOUReportAction && action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && network.isOffline ) { diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 55b294936f49..00ce20c19a85 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -346,7 +346,7 @@ function ReportActionItem(props) { const iouReportID = originalMessage.IOUReportID ? originalMessage.IOUReportID.toString() : '0'; children = ( Date: Fri, 19 Jan 2024 15:15:18 +0700 Subject: [PATCH 09/11] fix 33073 --- src/pages/home/report/ReportActionItem.js | 2 +- src/pages/home/report/ReportActionsView.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 00ce20c19a85..55b294936f49 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -346,7 +346,7 @@ function ReportActionItem(props) { const iouReportID = originalMessage.IOUReportID ? originalMessage.IOUReportID.toString() : '0'; children = ( _.size(props.reportActions) > 0); - const mostRecentIOUReportActionID = useInitialValue(() => ReportActionsUtils.getMostRecentIOURequestActionID(props.reportActions)); - + const mostRecentIOUReportActionID = useMemo(() => ReportActionsUtils.getMostRecentIOURequestActionID(props.reportActions), [props.reportActions]); const prevNetworkRef = useRef(props.network); const prevAuthTokenType = usePrevious(props.session.authTokenType); From 3bd59508671e60b0496f754cb935a95484ecc96e Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 19 Jan 2024 22:43:23 +0700 Subject: [PATCH 10/11] add comment --- src/pages/home/report/ReportActionItem.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 55b294936f49..60503424f663 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -346,6 +346,8 @@ function ReportActionItem(props) { const iouReportID = originalMessage.IOUReportID ? originalMessage.IOUReportID.toString() : '0'; children = ( Date: Tue, 23 Jan 2024 09:37:09 +0700 Subject: [PATCH 11/11] edit comment --- src/pages/home/report/ReportActionItem.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 60503424f663..80fb341a2cf8 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -346,8 +346,7 @@ function ReportActionItem(props) { const iouReportID = originalMessage.IOUReportID ? originalMessage.IOUReportID.toString() : '0'; children = (