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/37095: Tag list show required #37388

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useIsFocused} from '@react-navigation/native';
import {format} from 'date-fns';
import {isUndefined} from 'lodash';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {Fragment, useCallback, useEffect, useMemo, useReducer, useRef, useState} from 'react';
Expand Down Expand Up @@ -310,7 +311,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
const isMerchantRequired = isPolicyExpenseChat && !isScanRequest && shouldShowMerchant;

const isCategoryRequired = canUseViolations && lodashGet(policy, 'requiresCategory', false);
const isTagRequired = canUseViolations && lodashGet(policy, 'requiresTag', false);

useEffect(() => {
if ((!isMerchantRequired && isMerchantEmpty) || !merchantError) {
Expand Down Expand Up @@ -763,28 +763,38 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
shouldShow: shouldShowCategories,
isSupplementary: !isCategoryRequired,
},
..._.map(policyTagLists, ({name}, index) => ({
item: (
<MenuItemWithTopDescription
key={name}
shouldShowRightIcon={!isReadOnly}
title={TransactionUtils.getTagForDisplay(transaction, index)}
description={name}
numberOfLinesTitle={2}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.CREATE, iouType, index, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
)
}
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!isReadOnly}
rightLabel={isTagRequired ? translate('common.required') : ''}
/>
),
shouldShow: shouldShowTags,
isSupplementary: !isTagRequired,
})),
..._.map(policyTagLists, ({name, required}, index) => {
const isTagRequired = !isUndefined(required) && required;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we removed canUseViolations?
And this does not work for single level tags where required is not set for each tag, right?

Copy link
Contributor Author

@dukenv0307 dukenv0307 Mar 5, 2024

Choose a reason for hiding this comment

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

And this does not work for single level tags where required is not set for each tag, right?

In single-level tag, it still works because we also have required field. But we have the issue with BE side so that field is not returned correctly (Known issue mentioned here). Below is the data returned from BE side in case of single-level tag:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why we removed canUseViolations

I updated the PR to add the canUseViolations

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it still on HOLD? What PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MonilBhavsar @akinwale BE is fixed (See comment). I just tested it again and it works well

return {
item: (
<MenuItemWithTopDescription
key={name}
shouldShowRightIcon={!isReadOnly}
title={TransactionUtils.getTagForDisplay(transaction, index)}
description={name}
numberOfLinesTitle={2}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(
CONST.IOU.ACTION.CREATE,
iouType,
index,
transaction.transactionID,
reportID,
Navigation.getActiveRouteWithoutParams(),
),
)
}
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!isReadOnly}
rightLabel={isTagRequired ? translate('common.required') : ''}
/>
),
shouldShow: shouldShowTags,
isSupplementary: !isTagRequired,
};
}),
{
item: (
<MenuItemWithTopDescription
Expand Down
Loading