Skip to content
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

fix: revert approver button gray color for held expenses #54732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab5907a
fix: revert changes for report list item
mananjadhav Jan 1, 2025
e6e0f13
fix: revert changes for transaction, header and report preview
mananjadhav Jan 1, 2025
d6267ac
erge branch 'main' of github.com:mananjadhav/App into mj-revert-held-…
mananjadhav Jan 3, 2025
b83413a
Revert "Merge pull request #53117 from NJ-2020/fix/52569"
mananjadhav Jan 3, 2025
bb19649
fix: disable approve when any transaction is on hold
mananjadhav Jan 3, 2025
d095469
fix: disable dropdown only if all options are disabled
mananjadhav Jan 3, 2025
7b01a7e
fix: disable pay if any txns on hold
mananjadhav Jan 3, 2025
34fb3ad
refactor: lint fixes for default string
mananjadhav Jan 3, 2025
e022d9d
Merge branch 'main' of github.com:mananjadhav/App into mj-revert-held…
mananjadhav Jan 9, 2025
2a3302a
refactor: remove ws
mananjadhav Jan 9, 2025
324ca3b
Merge branch 'main' of github.com:mananjadhav/App into mj-revert-held…
mananjadhav Jan 14, 2025
f60b532
refactor: use named import
mananjadhav Jan 15, 2025
5b8d3f5
refactor: use named import
mananjadhav Jan 15, 2025
f0b63a3
refactor: use named import
mananjadhav Jan 15, 2025
9460c50
fix: adjust hover style for approve
mananjadhav Jan 15, 2025
73a033e
refactor: use named imports
mananjadhav Jan 15, 2025
d8795c8
refactor: use named imports
mananjadhav Jan 15, 2025
af8476d
refactor: use named imports
mananjadhav Jan 15, 2025
74f362e
Merge branch 'main' of github.com:mananjadhav/App into mj-revert-held…
mananjadhav Jan 15, 2025
c4cac41
Merge branch 'main' of github.com:mananjadhav/App into mj-revert-held…
mananjadhav Jan 16, 2025
01dfa6d
fix: button interaction on selected
mananjadhav Jan 16, 2025
16e7474
Merge branch 'main' of github.com:mananjadhav/App into mj-revert-held…
mananjadhav Jan 21, 2025
56d5fd4
revert: disabled buttons in popover
mananjadhav Jan 21, 2025
1ae3b67
Merge branch 'main' of github.com:mananjadhav/App into mj-revert-held…
mananjadhav Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/ButtonWithDropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function ButtonWithDropdownMenu<IValueType>({
// eslint-disable-next-line react-compiler/react-compiler
const dropdownButtonRef = isSplitButton ? buttonRef : mergeRefs(buttonRef, dropdownAnchor);
const selectedItem = options.at(selectedItemIndex) ?? options.at(0);
const areAllOptionsDisabled = options.every((option) => option.disabled);
const innerStyleDropButton = StyleUtils.getDropDownButtonHeight(buttonSize);
const isButtonSizeLarge = buttonSize === CONST.DROPDOWN_BUTTON_SIZE.LARGE;
const nullCheckRef = (ref: MutableRefObject<View | null>) => ref ?? null;
Expand Down Expand Up @@ -130,7 +131,7 @@ function ButtonWithDropdownMenu<IValueType>({
ref={dropdownButtonRef}
onPress={handlePress}
text={customText ?? selectedItem?.text ?? ''}
isDisabled={isDisabled || !!selectedItem?.disabled}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unnecessary for this PR.

Copy link
Collaborator Author

@mananjadhav mananjadhav Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hence, I posted the list of changes here to confirm what to retain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

isDisabled={isDisabled || areAllOptionsDisabled}
isLoading={isLoading}
shouldRemoveRightBorderRadius
style={isSplitButton ? [styles.flex1, styles.pr0] : {}}
Expand Down
3 changes: 0 additions & 3 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const policyType = policy?.type;
const connectedIntegration = getConnectedIntegration(policy);
const navigateBackToAfterDelete = useRef<Route>();
const hasHeldExpenses = hasHeldExpensesReportUtils(moneyRequestReport?.reportID);
const hasScanningReceipt = getTransactionsWithReceipts(moneyRequestReport?.reportID).some((t) => isReceiptBeingScanned(t));
const hasOnlyPendingTransactions = useMemo(() => {
return !!transactions && transactions.length > 0 && transactions.every((t) => isExpensifyCardTransaction(t) && isPending(t));
Expand Down Expand Up @@ -377,7 +376,6 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
{shouldShowSettlementButton && !shouldUseNarrowLayout && (
<View style={styles.pv2}>
<SettlementButton
shouldUseSuccessStyle={!hasHeldExpenses}
onlyShowPayElsewhere={onlyShowPayElsewhere}
currency={moneyRequestReport?.currency}
confirmApproval={confirmApproval}
Expand Down Expand Up @@ -443,7 +441,6 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
)}
{shouldShowSettlementButton && shouldUseNarrowLayout && (
<SettlementButton
shouldUseSuccessStyle={!hasHeldExpenses}
wrapperStyle={[styles.flex1]}
onlyShowPayElsewhere={onlyShowPayElsewhere}
currency={moneyRequestReport?.currency}
Expand Down
2 changes: 0 additions & 2 deletions src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ function ReportPreview({

const {nonHeldAmount, fullAmount, hasValidNonHeldAmount} = getNonHeldAndFullAmount(iouReport, shouldShowPayButton);
const hasOnlyHeldExpenses = hasOnlyHeldExpensesReportUtils(iouReport?.reportID);
const hasHeldExpenses = hasHeldExpensesReportUtils(iouReport?.reportID);

const managerID = iouReport?.managerID ?? action.childManagerAccountID ?? CONST.DEFAULT_NUMBER_ID;
const {totalDisplaySpend, reimbursableSpend} = getMoneyRequestSpendBreakdown(iouReport);
Expand Down Expand Up @@ -622,7 +621,6 @@ function ReportPreview({
</View>
{shouldShowSettlementButton && (
<AnimatedSettlementButton
shouldUseSuccessStyle={!hasHeldExpenses}
onlyShowPayElsewhere={onlyShowPayElsewhere}
isPaidAnimationRunning={isPaidAnimationRunning}
isApprovedAnimationRunning={isApprovedAnimationRunning}
Expand Down
22 changes: 5 additions & 17 deletions src/components/SelectionList/Search/ActionCell.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback} from 'react';
import React from 'react';
import {View} from 'react-native';
import Badge from '@components/Badge';
import Button from '@components/Button';
Expand All @@ -25,7 +25,6 @@ const actionTranslationsMap: Record<SearchTransactionAction, TranslationPaths> =

type ActionCellProps = {
action?: SearchTransactionAction;
shouldUseSuccessStyle?: boolean;
isLargeScreenWidth?: boolean;
isSelected?: boolean;
goToItem: () => void;
Expand All @@ -36,7 +35,6 @@ type ActionCellProps = {

function ActionCell({
action = CONST.SEARCH.ACTION_TYPES.VIEW,
shouldUseSuccessStyle: shouldUseSuccessStyleProp = true,
isLargeScreenWidth = true,
isSelected = false,
goToItem,
Expand All @@ -51,17 +49,6 @@ function ActionCell({
const {isOffline} = useNetwork();

const text = isChildListItem ? translate(actionTranslationsMap[CONST.SEARCH.ACTION_TYPES.VIEW]) : translate(actionTranslationsMap[action]);

const getButtonInnerStyles = useCallback(
(shouldUseSuccessStyle: boolean) => {
if (!isSelected) {
return {};
}
return shouldUseSuccessStyle ? styles.buttonSuccessHovered : styles.buttonDefaultHovered;
},
[isSelected, styles],
);

const shouldUseViewAction = action === CONST.SEARCH.ACTION_TYPES.VIEW || (parentAction === CONST.SEARCH.ACTION_TYPES.PAID && action === CONST.SEARCH.ACTION_TYPES.PAID);

if ((parentAction !== CONST.SEARCH.ACTION_TYPES.PAID && action === CONST.SEARCH.ACTION_TYPES.PAID) || action === CONST.SEARCH.ACTION_TYPES.DONE) {
Expand All @@ -88,13 +75,15 @@ function ActionCell({
}

if (action === CONST.SEARCH.ACTION_TYPES.VIEW || action === CONST.SEARCH.ACTION_TYPES.REVIEW || shouldUseViewAction) {
const buttonInnerStyles = isSelected ? styles.buttonDefaultSelected : {};

return isLargeScreenWidth ? (
<Button
text={text}
onPress={goToItem}
small
style={[styles.w100]}
innerStyles={getButtonInnerStyles(false)}
innerStyles={buttonInnerStyles}
link={isChildListItem}
shouldUseDefaultHover={!isChildListItem}
icon={!isChildListItem && action === CONST.SEARCH.ACTION_TYPES.REVIEW ? Expensicons.DotIndicator : undefined}
Expand All @@ -110,9 +99,8 @@ function ActionCell({
onPress={goToItem}
small
style={[styles.w100]}
innerStyles={getButtonInnerStyles(shouldUseSuccessStyleProp)}
isLoading={isLoading}
success={shouldUseSuccessStyleProp}
success
isDisabled={isOffline}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type ExpenseItemHeaderNarrowProps = {
containerStyle?: StyleProp<ViewStyle>;
onButtonPress: () => void;
canSelectMultiple?: boolean;
shouldUseSuccessStyle?: boolean;
isSelected?: boolean;
isDisabled?: boolean | null;
isDisabledCheckbox?: boolean;
Expand All @@ -42,7 +41,6 @@ function ExpenseItemHeaderNarrow({
canSelectMultiple,
containerStyle,
isDisabledCheckbox,
shouldUseSuccessStyle = true,
isSelected,
isDisabled,
handleCheckboxPress,
Expand Down Expand Up @@ -103,7 +101,6 @@ function ExpenseItemHeaderNarrow({
<View style={[StyleUtils.getWidthStyle(variables.w80)]}>
<ActionCell
action={action}
shouldUseSuccessStyle={shouldUseSuccessStyle}
goToItem={onButtonPress}
isLargeScreenWidth={false}
isSelected={isSelected}
Expand Down
9 changes: 2 additions & 7 deletions src/components/SelectionList/Search/ReportListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {handleActionButtonPress} from '@libs/actions/Search';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import {convertToDisplayString} from '@libs/CurrencyUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -47,7 +46,7 @@ function TotalCell({showTooltip, isLargeScreenWidth, reportItem}: ReportCellProp
return (
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={CurrencyUtils.convertToDisplayString(total, reportItem?.currency)}
text={convertToDisplayString(total, reportItem?.currency)}
style={[styles.optionDisplayName, styles.textNormal, styles.pre, styles.justifyContentCenter, isLargeScreenWidth ? undefined : styles.textAlignRight]}
/>
);
Expand Down Expand Up @@ -109,8 +108,6 @@ function ReportListItem<TItem extends ListItem>({
return null;
}

const hasHeldExpenses = ReportUtils.hasHeldExpenses('', reportItem.transactions);

const participantFrom = reportItem.from;
const participantTo = reportItem.to;

Expand Down Expand Up @@ -169,7 +166,6 @@ function ReportListItem<TItem extends ListItem>({
onButtonPress={handleOnButtonPress}
containerStyle={[styles.ph3, styles.pt1half, styles.mb1half]}
isLoading={reportItem.isActionLoading}
shouldUseSuccessStyle={!hasHeldExpenses}
/>
)}
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap3, styles.ph3, styles.pv1half]}>
Expand Down Expand Up @@ -202,7 +198,6 @@ function ReportListItem<TItem extends ListItem>({
<View style={StyleUtils.getSearchTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.ACTION)}>
<ActionCell
action={reportItem.action}
shouldUseSuccessStyle={!hasHeldExpenses}
goToItem={handleOnButtonPress}
isSelected={item.isSelected}
isLoading={reportItem.isActionLoading}
Expand Down
40 changes: 22 additions & 18 deletions src/components/SelectionList/Search/TransactionListItemRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Str} from 'expensify-common';
import React, {useMemo} from 'react';
import React from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {View} from 'react-native';
import Checkbox from '@components/Checkbox';
Expand All @@ -14,13 +14,21 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import {convertToDisplayString} from '@libs/CurrencyUtils';
import DateUtils from '@libs/DateUtils';
import {getFileName} from '@libs/fileDownload/FileUtils';
import Parser from '@libs/Parser';
import {getThumbnailAndImageURIs} from '@libs/ReceiptUtils';
import StringUtils from '@libs/StringUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import {
getTagForDisplay,
getTaxAmount,
getCreated as getTransactionCreated,
getCurrency as getTransactionCurrency,
getDescription as getTransactionDescription,
hasReceipt,
isReceiptBeingScanned,
} from '@libs/TransactionUtils';
import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot';
import variables from '@styles/variables';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -118,7 +126,7 @@ function ReceiptCell({transactionItem}: TransactionCellProps) {
function DateCell({transactionItem, showTooltip, isLargeScreenWidth}: TransactionCellProps) {
const styles = useThemeStyles();

const created = TransactionUtils.getCreated(transactionItem);
const created = getTransactionCreated(transactionItem);
const date = DateUtils.formatWithUTCTimeZone(created, DateUtils.doesDateBelongToAPastYear(created) ? CONST.DATE.MONTH_DAY_YEAR_ABBR_FORMAT : CONST.DATE.MONTH_DAY_ABBR_FORMAT);

return (
Expand All @@ -133,14 +141,14 @@ function DateCell({transactionItem, showTooltip, isLargeScreenWidth}: Transactio
function MerchantCell({transactionItem, showTooltip, isLargeScreenWidth}: TransactionCellProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const description = TransactionUtils.getDescription(transactionItem);
const description = getTransactionDescription(transactionItem);
let merchantOrDescriptionToDisplay = transactionItem.formattedMerchant;
if (!merchantOrDescriptionToDisplay && !isLargeScreenWidth) {
merchantOrDescriptionToDisplay = Parser.htmlToText(Parser.replace(description));
}
let merchant = transactionItem.shouldShowMerchant ? merchantOrDescriptionToDisplay : Parser.htmlToText(Parser.replace(description));

if (TransactionUtils.hasReceipt(transactionItem) && TransactionUtils.isReceiptBeingScanned(transactionItem) && transactionItem.shouldShowMerchant) {
if (hasReceipt(transactionItem) && isReceiptBeingScanned(transactionItem) && transactionItem.shouldShowMerchant) {
merchant = translate('iou.receiptStatusTitle');
}
const merchantToDisplay = StringUtils.getFirstLine(merchant);
Expand All @@ -156,10 +164,10 @@ function MerchantCell({transactionItem, showTooltip, isLargeScreenWidth}: Transa
function TotalCell({showTooltip, isLargeScreenWidth, transactionItem}: TotalCellProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const currency = TransactionUtils.getCurrency(transactionItem);
let amount = CurrencyUtils.convertToDisplayString(transactionItem.formattedTotal, currency);
const currency = getTransactionCurrency(transactionItem);
let amount = convertToDisplayString(transactionItem.formattedTotal, currency);

if (TransactionUtils.hasReceipt(transactionItem) && TransactionUtils.isReceiptBeingScanned(transactionItem)) {
if (hasReceipt(transactionItem) && isReceiptBeingScanned(transactionItem)) {
amount = translate('iou.receiptStatusTitle');
}

Expand Down Expand Up @@ -216,14 +224,14 @@ function TagCell({isLargeScreenWidth, showTooltip, transactionItem}: Transaction
return isLargeScreenWidth ? (
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={TransactionUtils.getTagForDisplay(transactionItem)}
text={getTagForDisplay(transactionItem)}
style={[styles.optionDisplayName, styles.lineHeightLarge, styles.pre, styles.justifyContentCenter]}
/>
) : (
<TextWithIconCell
icon={Expensicons.Tag}
showTooltip={showTooltip}
text={TransactionUtils.getTagForDisplay(transactionItem)}
text={getTagForDisplay(transactionItem)}
textStyle={[styles.textMicro, styles.mnh0]}
/>
);
Expand All @@ -233,13 +241,13 @@ function TaxCell({transactionItem, showTooltip}: TransactionCellProps) {
const styles = useThemeStyles();

const isFromExpenseReport = transactionItem.reportType === CONST.REPORT.TYPE.EXPENSE;
const taxAmount = TransactionUtils.getTaxAmount(transactionItem, isFromExpenseReport);
const currency = TransactionUtils.getCurrency(transactionItem);
const taxAmount = getTaxAmount(transactionItem, isFromExpenseReport);
const currency = getTransactionCurrency(transactionItem);

return (
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={CurrencyUtils.convertToDisplayString(taxAmount, currency)}
text={convertToDisplayString(taxAmount, currency)}
style={[styles.optionDisplayName, styles.lineHeightLarge, styles.pre, styles.justifyContentCenter, styles.textAlignRight]}
/>
);
Expand All @@ -265,8 +273,6 @@ function TransactionListItemRow({
const StyleUtils = useStyleUtils();
const theme = useTheme();

const isOnHold = useMemo(() => TransactionUtils.isOnHold(item), [item]);

if (!isLargeScreenWidth) {
return (
<View style={containerStyle}>
Expand All @@ -280,7 +286,6 @@ function TransactionListItemRow({
onButtonPress={onButtonPress}
canSelectMultiple={canSelectMultiple}
action={item.action}
shouldUseSuccessStyle={!isOnHold}
isSelected={item.isSelected}
isDisabled={item.isDisabled}
isDisabledCheckbox={item.isDisabledCheckbox}
Expand Down Expand Up @@ -447,7 +452,6 @@ function TransactionListItemRow({
<View style={[StyleUtils.getSearchTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.ACTION)]}>
<ActionCell
action={item.action}
shouldUseSuccessStyle={!isOnHold}
isSelected={isButtonSelected}
isChildListItem={isChildListItem}
parentAction={parentAction}
Expand Down
Loading