From 158e5e66f3af413a53a405f18c009b28b508dab1 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 22 Jan 2024 12:06:43 -0700 Subject: [PATCH 01/22] calculate reimbursable total based on total and nonReimbursableTotal --- src/libs/ReportUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 78086c354de0..982ff286932b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1811,13 +1811,13 @@ function getMoneyRequestReimbursableTotal(report: OnyxEntry, allReportsD moneyRequestReport = allAvailableReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`]; } if (moneyRequestReport) { - const total = moneyRequestReport?.total ?? 0; + const reimbursableTotal = (moneyRequestReport?.total ?? 0) - (moneyRequestReport?.nonReimbursableTotal ?? 0); - if (total !== 0) { + if (reimbursableTotal !== 0) { // There is a possibility that if the Expense report has a negative total. // This is because there are instances where you can get a credit back on your card, // or you enter a negative expense to “offset” future expenses - return isExpenseReport(moneyRequestReport) ? total * -1 : Math.abs(total); + return isExpenseReport(moneyRequestReport) ? reimbursableTotal * -1 : Math.abs(reimbursableTotal); } } return 0; From 09e90dd42268f798b7e581e2022ea36841a3901f Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 22 Jan 2024 12:12:59 -0700 Subject: [PATCH 02/22] revert changes --- src/libs/ReportUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 982ff286932b..78086c354de0 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1811,13 +1811,13 @@ function getMoneyRequestReimbursableTotal(report: OnyxEntry, allReportsD moneyRequestReport = allAvailableReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`]; } if (moneyRequestReport) { - const reimbursableTotal = (moneyRequestReport?.total ?? 0) - (moneyRequestReport?.nonReimbursableTotal ?? 0); + const total = moneyRequestReport?.total ?? 0; - if (reimbursableTotal !== 0) { + if (total !== 0) { // There is a possibility that if the Expense report has a negative total. // This is because there are instances where you can get a credit back on your card, // or you enter a negative expense to “offset” future expenses - return isExpenseReport(moneyRequestReport) ? reimbursableTotal * -1 : Math.abs(reimbursableTotal); + return isExpenseReport(moneyRequestReport) ? total * -1 : Math.abs(total); } } return 0; From 0ddc19813ee488fbb7f54797f462da9beb007d83 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 22 Jan 2024 12:13:49 -0700 Subject: [PATCH 03/22] use getMoneyRequestSpendBreakdown --- src/components/MoneyReportHeader.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index afdc62218f95..b69fe63bb638 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -52,7 +52,7 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, nextSt const styles = useThemeStyles(); const {translate} = useLocalize(); const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); - const reimbursableTotal = ReportUtils.getMoneyRequestReimbursableTotal(moneyRequestReport); + const {reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(moneyRequestReport); const isApproved = ReportUtils.isReportApproved(moneyRequestReport); const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID); const policyType = policy?.type; @@ -65,8 +65,8 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, nextSt : isPolicyAdmin || (ReportUtils.isMoneyRequestReport(moneyRequestReport) && isManager); const isDraft = ReportUtils.isDraftExpenseReport(moneyRequestReport); const shouldShowPayButton = useMemo( - () => isPayer && !isDraft && !isSettled && !moneyRequestReport.isWaitingOnBankAccount && reimbursableTotal !== 0 && !ReportUtils.isArchivedRoom(chatReport), - [isPayer, isDraft, isSettled, moneyRequestReport, reimbursableTotal, chatReport], + () => isPayer && !isDraft && !isSettled && !moneyRequestReport.isWaitingOnBankAccount && reimbursableSpend !== 0 && !ReportUtils.isArchivedRoom(chatReport), + [isPayer, isDraft, isSettled, moneyRequestReport, reimbursableSpend, chatReport], ); const shouldShowApproveButton = useMemo(() => { if (!isPaidGroupPolicy) { @@ -75,12 +75,12 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, nextSt return isManager && !isDraft && !isApproved && !isSettled; }, [isPaidGroupPolicy, isManager, isDraft, isApproved, isSettled]); const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton; - const shouldShowSubmitButton = isDraft && reimbursableTotal !== 0; + const shouldShowSubmitButton = isDraft && reimbursableSpend !== 0; const isFromPaidPolicy = policyType === CONST.POLICY.TYPE.TEAM || policyType === CONST.POLICY.TYPE.CORPORATE; const shouldShowNextStep = isFromPaidPolicy && !!nextStep?.message?.length; const shouldShowAnyButton = shouldShowSettlementButton || shouldShowApproveButton || shouldShowSubmitButton || shouldShowNextStep; const bankAccountRoute = ReportUtils.getBankAccountRoute(chatReport); - const formattedAmount = CurrencyUtils.convertToDisplayString(reimbursableTotal, moneyRequestReport.currency); + const formattedAmount = CurrencyUtils.convertToDisplayString(reimbursableSpend, moneyRequestReport.currency); const isMoreContentShown = shouldShowNextStep || (shouldShowAnyButton && isSmallScreenWidth); // The submit button should be success green colour only if the user is submitter and the policy does not have Scheduled Submit turned on From 25595f98f3a5cda690d7fc6d01a77e7117fa2a24 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 22 Jan 2024 12:15:19 -0700 Subject: [PATCH 04/22] rename getMoneyRequestReimbursableTotal to getMoneyRequestTotal --- src/libs/OptionsListUtils.js | 2 +- src/libs/ReportUtils.ts | 10 +++++----- src/libs/SidebarUtils.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index e86c9daacb42..724c6465bdce 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -568,7 +568,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, { } result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result); - result.iouReportAmount = ReportUtils.getMoneyRequestReimbursableTotal(result); + result.iouReportAmount = ReportUtils.getMoneyRequestTotal(result); if (!hasMultipleParticipants) { result.login = personalDetail.login; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 78086c354de0..49e310bcadc8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1801,7 +1801,7 @@ function hasNonReimbursableTransactions(iouReportID: string | undefined): boolea return transactions.filter((transaction) => transaction.reimbursable === false).length > 0; } -function getMoneyRequestReimbursableTotal(report: OnyxEntry, allReportsDict: OnyxCollection = null): number { +function getMoneyRequestTotal(report: OnyxEntry, allReportsDict: OnyxCollection = null): number { const allAvailableReports = allReportsDict ?? allReports; let moneyRequestReport: OnyxEntry | undefined; if (isMoneyRequestReport(report)) { @@ -1903,7 +1903,7 @@ function getPolicyExpenseChatName(report: OnyxEntry, policy: OnyxEntry

, policy: OnyxEntry | undefined = undefined): string { - const moneyRequestTotal = getMoneyRequestReimbursableTotal(report); + const moneyRequestTotal = getMoneyRequestTotal(report); const formattedAmount = CurrencyUtils.convertToDisplayString(moneyRequestTotal, report?.currency, hasOnlyDistanceRequestTransactions(report?.reportID)); const payerOrApproverName = isExpenseReport(report) ? getPolicyName(report, false, policy) : getDisplayNameForParticipant(report?.managerID) ?? ''; const payerPaidAmountMessage = Localize.translateLocal('iou.payerPaidAmount', { @@ -2203,7 +2203,7 @@ function getReportPreviewMessage( } } - const totalAmount = getMoneyRequestReimbursableTotal(report); + const totalAmount = getMoneyRequestTotal(report); const policyName = getPolicyName(report, false, policy); const payerName = isExpenseReport(report) ? policyName : getDisplayNameForParticipant(report.managerID, !isPreviewMessageForParentChatReport); @@ -2746,7 +2746,7 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num const report = getReport(iouReportID); const amount = type === CONST.IOU.REPORT_ACTION_TYPE.PAY - ? CurrencyUtils.convertToDisplayString(getMoneyRequestReimbursableTotal(!isEmptyObject(report) ? report : null), currency) + ? CurrencyUtils.convertToDisplayString(getMoneyRequestTotal(!isEmptyObject(report) ? report : null), currency) : CurrencyUtils.convertToDisplayString(total, currency); let paymentMethodMessage; @@ -4593,7 +4593,7 @@ export { hasExpensifyGuidesEmails, requiresAttentionFromCurrentUser, isIOUOwnedByCurrentUser, - getMoneyRequestReimbursableTotal, + getMoneyRequestTotal, getMoneyRequestSpendBreakdown, canShowReportRecipientLocalTime, formatReportLastMessageText, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 445d9dc30dd8..0548c4071330 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -199,7 +199,7 @@ function getOrderedReportIDs( report.displayName = ReportUtils.getReportName(report); // eslint-disable-next-line no-param-reassign - report.iouReportAmount = ReportUtils.getMoneyRequestReimbursableTotal(report, allReports); + report.iouReportAmount = ReportUtils.getMoneyRequestTotal(report, allReports); const isPinned = report.isPinned ?? false; const reportAction = ReportActionsUtils.getReportAction(report.parentReportID ?? '', report.parentReportActionID ?? ''); @@ -458,7 +458,7 @@ function getOptionData({ } result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result as Report); - result.iouReportAmount = ReportUtils.getMoneyRequestReimbursableTotal(result as Report); + result.iouReportAmount = ReportUtils.getMoneyRequestTotal(result as Report); if (!hasMultipleParticipants) { result.accountID = personalDetail.accountID; From 1be02bcbdb657af69134eaac589d5b80b3f96ac7 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 22 Jan 2024 12:27:38 -0700 Subject: [PATCH 05/22] delete getMoneyRequestReimbursableTotal --- src/libs/OptionsListUtils.js | 2 +- src/libs/ReportUtils.ts | 29 +++-------------------------- src/libs/SidebarUtils.ts | 4 ++-- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 724c6465bdce..beab49818fa0 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -568,7 +568,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, { } result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result); - result.iouReportAmount = ReportUtils.getMoneyRequestTotal(result); + result.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(result).totalDisplaySpend; if (!hasMultipleParticipants) { result.login = personalDetail.login; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 49e310bcadc8..ab06125a828c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1801,28 +1801,6 @@ function hasNonReimbursableTransactions(iouReportID: string | undefined): boolea return transactions.filter((transaction) => transaction.reimbursable === false).length > 0; } -function getMoneyRequestTotal(report: OnyxEntry, allReportsDict: OnyxCollection = null): number { - const allAvailableReports = allReportsDict ?? allReports; - let moneyRequestReport: OnyxEntry | undefined; - if (isMoneyRequestReport(report)) { - moneyRequestReport = report; - } - if (allAvailableReports && report?.iouReportID) { - moneyRequestReport = allAvailableReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`]; - } - if (moneyRequestReport) { - const total = moneyRequestReport?.total ?? 0; - - if (total !== 0) { - // There is a possibility that if the Expense report has a negative total. - // This is because there are instances where you can get a credit back on your card, - // or you enter a negative expense to “offset” future expenses - return isExpenseReport(moneyRequestReport) ? total * -1 : Math.abs(total); - } - } - return 0; -} - function getMoneyRequestSpendBreakdown(report: OnyxEntry, allReportsDict: OnyxCollection = null): SpendBreakdown { const allAvailableReports = allReportsDict ?? allReports; let moneyRequestReport; @@ -1903,7 +1881,7 @@ function getPolicyExpenseChatName(report: OnyxEntry, policy: OnyxEntry

, policy: OnyxEntry | undefined = undefined): string { - const moneyRequestTotal = getMoneyRequestTotal(report); + const moneyRequestTotal = getMoneyRequestSpendBreakdown(report).totalDisplaySpend; const formattedAmount = CurrencyUtils.convertToDisplayString(moneyRequestTotal, report?.currency, hasOnlyDistanceRequestTransactions(report?.reportID)); const payerOrApproverName = isExpenseReport(report) ? getPolicyName(report, false, policy) : getDisplayNameForParticipant(report?.managerID) ?? ''; const payerPaidAmountMessage = Localize.translateLocal('iou.payerPaidAmount', { @@ -2203,7 +2181,7 @@ function getReportPreviewMessage( } } - const totalAmount = getMoneyRequestTotal(report); + const totalAmount = getMoneyRequestSpendBreakdown(report).totalDisplaySpend; const policyName = getPolicyName(report, false, policy); const payerName = isExpenseReport(report) ? policyName : getDisplayNameForParticipant(report.managerID, !isPreviewMessageForParentChatReport); @@ -2746,7 +2724,7 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num const report = getReport(iouReportID); const amount = type === CONST.IOU.REPORT_ACTION_TYPE.PAY - ? CurrencyUtils.convertToDisplayString(getMoneyRequestTotal(!isEmptyObject(report) ? report : null), currency) + ? CurrencyUtils.convertToDisplayString(getMoneyRequestSpendBreakdown(!isEmptyObject(report) ? report : null).totalDisplaySpend, currency) : CurrencyUtils.convertToDisplayString(total, currency); let paymentMethodMessage; @@ -4593,7 +4571,6 @@ export { hasExpensifyGuidesEmails, requiresAttentionFromCurrentUser, isIOUOwnedByCurrentUser, - getMoneyRequestTotal, getMoneyRequestSpendBreakdown, canShowReportRecipientLocalTime, formatReportLastMessageText, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 0548c4071330..a3208208dbc2 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -199,7 +199,7 @@ function getOrderedReportIDs( report.displayName = ReportUtils.getReportName(report); // eslint-disable-next-line no-param-reassign - report.iouReportAmount = ReportUtils.getMoneyRequestTotal(report, allReports); + report.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(report, allReports).totalDisplaySpend; const isPinned = report.isPinned ?? false; const reportAction = ReportActionsUtils.getReportAction(report.parentReportID ?? '', report.parentReportActionID ?? ''); @@ -458,7 +458,7 @@ function getOptionData({ } result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result as Report); - result.iouReportAmount = ReportUtils.getMoneyRequestTotal(result as Report); + result.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(result as Report).totalDisplaySpend; if (!hasMultipleParticipants) { result.accountID = personalDetail.accountID; From 1a75ea271c99bfcf2f5f0d804b9406f5b447dcf1 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 23 Jan 2024 16:31:56 +0800 Subject: [PATCH 06/22] show scrollbar by default --- src/components/OptionsList/BaseOptionsList.tsx | 2 +- src/components/SelectionList/BaseSelectionList.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/OptionsList/BaseOptionsList.tsx b/src/components/OptionsList/BaseOptionsList.tsx index c1e4562a0c2d..174b2e14a18a 100644 --- a/src/components/OptionsList/BaseOptionsList.tsx +++ b/src/components/OptionsList/BaseOptionsList.tsx @@ -33,7 +33,7 @@ function BaseOptionsList( optionHoveredStyle, contentContainerStyles, sectionHeaderStyle, - showScrollIndicator = false, + showScrollIndicator = true, listContainerStyles: listContainerStylesProp, shouldDisableRowInnerPadding = false, shouldPreventDefaultFocusOnSelectRow = false, diff --git a/src/components/SelectionList/BaseSelectionList.js b/src/components/SelectionList/BaseSelectionList.js index 960618808fd9..93841c5a885e 100644 --- a/src/components/SelectionList/BaseSelectionList.js +++ b/src/components/SelectionList/BaseSelectionList.js @@ -52,7 +52,7 @@ function BaseSelectionList({ onConfirm, headerContent, footerContent, - showScrollIndicator = false, + showScrollIndicator = true, showLoadingPlaceholder = false, showConfirmButton = false, shouldPreventDefaultFocusOnSelectRow = false, From 586936980f8e7728f9ec04544e2697ef31c63d71 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 23 Jan 2024 16:32:21 +0800 Subject: [PATCH 07/22] fix wrong indicator style --- src/components/OptionsList/BaseOptionsList.tsx | 1 - src/components/SelectionList/BaseSelectionList.js | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/components/OptionsList/BaseOptionsList.tsx b/src/components/OptionsList/BaseOptionsList.tsx index 174b2e14a18a..4619cd8ac361 100644 --- a/src/components/OptionsList/BaseOptionsList.tsx +++ b/src/components/OptionsList/BaseOptionsList.tsx @@ -241,7 +241,6 @@ function BaseOptionsList( ref={ref} style={listStyles} - indicatorStyle="white" keyboardShouldPersistTaps="always" keyboardDismissMode={keyboardDismissMode} nestedScrollEnabled={nestedScrollEnabled} diff --git a/src/components/SelectionList/BaseSelectionList.js b/src/components/SelectionList/BaseSelectionList.js index 93841c5a885e..e0c0a56b994d 100644 --- a/src/components/SelectionList/BaseSelectionList.js +++ b/src/components/SelectionList/BaseSelectionList.js @@ -18,7 +18,6 @@ import useActiveElementRole from '@hooks/useActiveElementRole'; import useKeyboardShortcut from '@hooks/useKeyboardShortcut'; import useLocalize from '@hooks/useLocalize'; import useStyleUtils from '@hooks/useStyleUtils'; -import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import Log from '@libs/Log'; import variables from '@styles/variables'; @@ -67,7 +66,6 @@ function BaseSelectionList({ shouldUseDynamicMaxToRenderPerBatch = false, rightHandSideComponent, }) { - const theme = useTheme(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); @@ -474,7 +472,6 @@ function BaseSelectionList({ onScrollBeginDrag={onScrollBeginDrag} keyExtractor={(item) => item.keyForList} extraData={focusedIndex} - indicatorStyle={theme.white} keyboardShouldPersistTaps="always" showsVerticalScrollIndicator={showScrollIndicator} initialNumToRender={12} From cd01c9a018ddbbe52a9426efc031dafc3dd6896f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 23 Jan 2024 16:53:29 +0800 Subject: [PATCH 08/22] add back indicator style --- src/components/OptionsList/BaseOptionsList.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/OptionsList/BaseOptionsList.tsx b/src/components/OptionsList/BaseOptionsList.tsx index 4619cd8ac361..174b2e14a18a 100644 --- a/src/components/OptionsList/BaseOptionsList.tsx +++ b/src/components/OptionsList/BaseOptionsList.tsx @@ -241,6 +241,7 @@ function BaseOptionsList( ref={ref} style={listStyles} + indicatorStyle="white" keyboardShouldPersistTaps="always" keyboardDismissMode={keyboardDismissMode} nestedScrollEnabled={nestedScrollEnabled} From d766e84ad1f1af2aacb10b71e00cbb13a17e1a5c Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Tue, 23 Jan 2024 08:35:20 -0600 Subject: [PATCH 09/22] fix: call signOutAndRedirectToSignIn with no parameter --- src/pages/home/sidebar/SignInButton.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/sidebar/SignInButton.js b/src/pages/home/sidebar/SignInButton.js index 9edcc9584dbd..f89deb6f65b2 100644 --- a/src/pages/home/sidebar/SignInButton.js +++ b/src/pages/home/sidebar/SignInButton.js @@ -16,14 +16,14 @@ function SignInButton() { Session.signOutAndRedirectToSignIn()} >