Repository navigation
Report Actions Derived Value #81280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report Actions Derived Value #81280
Changes from all commits
9b022b4
e02cfaf
5d15693
08677b0
887c55c
b7eee34
4244f95
fd2d8b8
658d03e
e3c65df
2da11ff
8140cf0
c9d13e4
a6e6606
166f94a
cd6457e
9c616e4
ae9e7b2
e660915
b4d7ae7
e86bf70
f64066f
015c37d
2ce6241
d373cbd
1d9b90e
66a9a30
e22d6a6
4aab126
11d8cc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ | |
| import useLocalize from '@hooks/useLocalize'; | ||
| import useNetwork from '@hooks/useNetwork'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses'; | ||
| import usePrevious from '@hooks/usePrevious'; | ||
| import useReportAttributes from '@hooks/useReportAttributes'; | ||
| import useRootNavigationState from '@hooks/useRootNavigationState'; | ||
|
|
@@ -25,15 +24,14 @@ | |
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import getPlatform from '@libs/getPlatform'; | ||
| import Log from '@libs/Log'; | ||
| import {getMovedReportID} from '@libs/ModifiedExpenseMessage'; | ||
| import {getIOUReportIDOfLastAction, getLastMessageTextForReport} from '@libs/OptionsListUtils'; | ||
| import {findLastReportActions, getOriginalMessage, isInviteOrRemovedAction, isMoneyRequestAction} from '@libs/ReportActionsUtils'; | ||
| import {getIOUReportIDOfLastAction} from '@libs/OptionsListUtils'; | ||
| import {getLastVisibleActionIncludingTransactionThread, getOriginalMessage, isActionableTrackExpense, isInviteOrRemovedAction, isMoneyRequestAction} from '@libs/ReportActionsUtils'; | ||
| import {canUserPerformWriteAction as canUserPerformWriteActionUtil} from '@libs/ReportUtils'; | ||
| import variables from '@styles/variables'; | ||
| import CONST from '@src/CONST'; | ||
| import NAVIGATORS from '@src/NAVIGATORS'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {PersonalDetails, Report} from '@src/types/onyx'; | ||
| import type {Report} from '@src/types/onyx'; | ||
| import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
| import OptionRowLHNData from './OptionRowLHNData'; | ||
| import OptionRowRendererComponent from './OptionRowRendererComponent'; | ||
|
|
@@ -53,7 +51,6 @@ | |
| const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); | ||
| const reportAttributes = useReportAttributes(); | ||
| const [reportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS); | ||
| const [reportMetadataCollection] = useOnyx(ONYXKEYS.COLLECTION.REPORT_METADATA); | ||
| const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS); | ||
| const [policy] = useOnyx(ONYXKEYS.COLLECTION.POLICY); | ||
| const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); | ||
|
|
@@ -64,8 +61,8 @@ | |
| const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); | ||
| const [onboarding] = useOnyx(ONYXKEYS.NVP_ONBOARDING); | ||
| const [isFullscreenVisible] = useOnyx(ONYXKEYS.FULLSCREEN_VISIBILITY); | ||
| const [visibleReportActionsData] = useOnyx(ONYXKEYS.DERIVED.VISIBLE_REPORT_ACTIONS); | ||
| const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); | ||
| const {policyForMovingExpensesID} = usePolicyForMovingExpenses(); | ||
|
|
||
| const theme = useTheme(); | ||
| const styles = useThemeStyles(); | ||
|
|
@@ -184,9 +181,6 @@ | |
| } | ||
| const itemInvoiceReceiverPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${invoiceReceiverPolicyID}`]; | ||
|
|
||
| const iouReportIDOfLastAction = getIOUReportIDOfLastAction(item); | ||
| const itemIouReportReportActions = iouReportIDOfLastAction ? reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportIDOfLastAction}`] : undefined; | ||
|
|
||
| const itemPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${item?.policyID}`]; | ||
| const transactionID = isMoneyRequestAction(itemParentReportAction) | ||
| ? (getOriginalMessage(itemParentReportAction)?.IOUTransactionID ?? CONST.DEFAULT_NUMBER_ID) | ||
|
|
@@ -198,42 +192,29 @@ | |
|
|
||
| const isReportArchived = !!itemReportNameValuePairs?.private_isArchived; | ||
| const canUserPerformWrite = canUserPerformWriteActionUtil(item, isReportArchived); | ||
| const {lastVisibleAction: lastReportAction, lastActionForDisplay: lastAction} = findLastReportActions(itemReportActions, canUserPerformWrite); | ||
|
|
||
| // Get the transaction for the last report action | ||
| const lastReportActionTransactionID = isMoneyRequestAction(lastReportAction) | ||
| ? (getOriginalMessage(lastReportAction)?.IOUTransactionID ?? CONST.DEFAULT_NUMBER_ID) | ||
| : CONST.DEFAULT_NUMBER_ID; | ||
| const lastAction = getLastVisibleActionIncludingTransactionThread( | ||
| reportID, | ||
| canUserPerformWrite, | ||
| reportActions, | ||
| visibleReportActionsData, | ||
| itemOneTransactionThreadReport?.reportID, | ||
| ); | ||
|
|
||
| const iouReportIDOfLastAction = getIOUReportIDOfLastAction(item, visibleReportActionsData, lastAction); | ||
| const itemIouReportReportActions = iouReportIDOfLastAction ? reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportIDOfLastAction}`] : undefined; | ||
|
|
||
| const lastReportActionTransactionID = isMoneyRequestAction(lastAction) ? (getOriginalMessage(lastAction)?.IOUTransactionID ?? CONST.DEFAULT_NUMBER_ID) : CONST.DEFAULT_NUMBER_ID; | ||
| const lastReportActionTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${lastReportActionTransactionID}`]; | ||
|
|
||
| // SidebarUtils.getOptionData in OptionRowLHNData does not get re-evaluated when the linked task report changes, so we have the lastMessageTextFromReport evaluation logic here | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed this doen't reintroduce original bug #48285 |
||
| let lastActorDetails: Partial<PersonalDetails> | null = item?.lastActorAccountID && personalDetails?.[item.lastActorAccountID] ? personalDetails[item.lastActorAccountID] : null; | ||
| if (!lastActorDetails && lastReportAction) { | ||
| const lastActorDisplayName = lastReportAction?.person?.[0]?.text; | ||
| lastActorDetails = lastActorDisplayName | ||
| ? { | ||
| displayName: lastActorDisplayName, | ||
| accountID: item?.lastActorAccountID, | ||
| } | ||
| : null; | ||
| // Only override lastMessageTextFromReport when a track expense whisper's transaction has been deleted, to prevent showing stale text. | ||
| let lastMessageTextFromReport: string | undefined; | ||
| if (isActionableTrackExpense(lastAction)) { | ||
| const whisperTransactionID = getOriginalMessage(lastAction)?.transactionID; | ||
| if (whisperTransactionID && !transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${whisperTransactionID}`]) { | ||
|
Comment on lines
+210
to
+214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎.
BartekObudzinski marked this conversation as resolved.
|
||
| lastMessageTextFromReport = ''; | ||
| } | ||
| } | ||
| const movedFromReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${getMovedReportID(lastReportAction, CONST.REPORT.MOVE_TYPE.FROM)}`]; | ||
| const movedToReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${getMovedReportID(lastReportAction, CONST.REPORT.MOVE_TYPE.TO)}`]; | ||
| const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${item?.chatReportID}`]; | ||
| const itemReportMetadata = reportMetadataCollection?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`]; | ||
| const lastMessageTextFromReport = getLastMessageTextForReport({ | ||
| translate, | ||
| report: item, | ||
| lastActorDetails, | ||
| movedFromReport, | ||
| movedToReport, | ||
| policy: itemPolicy, | ||
| isReportArchived: !!itemReportNameValuePairs?.private_isArchived, | ||
| policyForMovingExpensesID, | ||
| reportMetadata: itemReportMetadata, | ||
| chatReport, | ||
| reportAttributesDerived: reportAttributes, | ||
| }); | ||
|
|
||
| const shouldShowRBRorGBRTooltip = firstReportIDWithGBRorRBR === reportID; | ||
|
|
||
|
|
@@ -285,18 +266,16 @@ | |
| /> | ||
| ); | ||
| }, | ||
| [ | ||
|
Check warning on line 269 in src/components/LHNOptionsList/LHNOptionsList.tsx
|
||
| reports, | ||
| reportNameValuePairs, | ||
| reportActions, | ||
| reportMetadataCollection, | ||
| isOffline, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed |
||
| reportAttributes, | ||
| policy, | ||
| transactions, | ||
| draftComments, | ||
| personalDetails, | ||
| policyForMovingExpensesID, | ||
| firstReportIDWithGBRorRBR, | ||
| optionMode, | ||
| shouldDisableFocusOptions, | ||
|
|
@@ -312,6 +291,7 @@ | |
| isScreenFocused, | ||
| localeCompare, | ||
| translate, | ||
| visibleReportActionsData, | ||
| currentUserAccountID, | ||
| ], | ||
| ); | ||
|
|
@@ -333,6 +313,7 @@ | |
| isOffline, | ||
| isScreenFocused, | ||
| isReportsSplitNavigatorLast, | ||
| visibleReportActionsData, | ||
| ], | ||
| [ | ||
| reportActions, | ||
|
|
@@ -350,6 +331,7 @@ | |
| isOffline, | ||
| isScreenFocused, | ||
| isReportsSplitNavigatorLast, | ||
| visibleReportActionsData, | ||
| ], | ||
| ); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.