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

Revert "fix: Taxes - App allows deleted tax rate to be selected as currency default in offline mode." #42953

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion src/components/SelectionList/RadioListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function RadioListItem<TItem extends ListItem>({
keyForList={item.keyForList}
onFocus={onFocus}
shouldSyncFocus={shouldSyncFocus}
pendingAction={item.pendingAction}
>
<>
<View style={[styles.flex1, styles.alignItemsStart]}>
Expand Down
2 changes: 0 additions & 2 deletions src/components/TagPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import type * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PolicyTag, PolicyTagList, PolicyTags, RecentlyUsedTags} from '@src/types/onyx';
import type {PendingAction} from '@src/types/onyx/OnyxCommon';

type SelectedTagOption = {
name: string;
enabled: boolean;
isSelected?: boolean;
accountID: number | undefined;
pendingAction?: PendingAction;
};

type TagPickerOnyxProps = {
Expand Down
30 changes: 9 additions & 21 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ type OptionTree = {
tooltipText: string;
isDisabled: boolean;
isSelected: boolean;
pendingAction?: OnyxCommon.PendingAction;
} & Option;

type PayeePersonalDetails = {
Expand Down Expand Up @@ -108,7 +107,6 @@ type TaxRatesOption = {
isDisabled?: boolean;
keyForList?: string;
isSelected?: boolean;
pendingAction?: OnyxCommon.PendingAction;
};

type TaxSection = {
Expand All @@ -126,7 +124,6 @@ type Category = {
name: string;
enabled: boolean;
isSelected?: boolean;
pendingAction?: OnyxCommon.PendingAction;
};

type Tax = {
Expand Down Expand Up @@ -953,7 +950,6 @@ function sortCategories(categories: Record<string, Category>): Category[] {
lodashSet(hierarchy, path, {
...existedValue,
name: category.name,
pendingAction: category.pendingAction,
});
});

Expand All @@ -964,11 +960,10 @@ function sortCategories(categories: Record<string, Category>): Category[] {
*/
const flatHierarchy = (initialHierarchy: Hierarchy) =>
Object.values(initialHierarchy).reduce((acc: Category[], category) => {
const {name, pendingAction, ...subcategories} = category;
const {name, ...subcategories} = category;
if (name) {
const categoryObject: Category = {
name,
pendingAction,
enabled: categories[name]?.enabled ?? false,
};

Expand Down Expand Up @@ -1018,9 +1013,8 @@ function getCategoryOptionTree(options: Record<string, Category> | Category[], i
keyForList: option.name,
searchText: option.name,
tooltipText: option.name,
isDisabled: !option.enabled || option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
isDisabled: !option.enabled,
isSelected: !!option.isSelected,
pendingAction: option.pendingAction,
});

return;
Expand All @@ -1040,9 +1034,8 @@ function getCategoryOptionTree(options: Record<string, Category> | Category[], i
keyForList: searchText,
searchText,
tooltipText: optionName,
isDisabled: isChild ? !option.enabled || option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE : true,
isDisabled: isChild ? !option.enabled : true,
isSelected: isChild ? !!option.isSelected : selectedOptionsName.includes(searchText),
pendingAction: option.pendingAction,
});
});
});
Expand Down Expand Up @@ -1142,10 +1135,7 @@ function getCategoryListSections(
}

const filteredRecentlyUsedCategories = recentlyUsedCategories
.filter(
(categoryName) =>
!selectedOptionNames.includes(categoryName) && categories[categoryName]?.enabled && categories[categoryName]?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
)
.filter((categoryName) => !selectedOptionNames.includes(categoryName) && categories[categoryName]?.enabled)
.map((categoryName) => ({
name: categoryName,
enabled: categories[categoryName].enabled ?? false,
Expand Down Expand Up @@ -1181,7 +1171,7 @@ function getCategoryListSections(
*
* @param tags - an initial tag array
*/
function getTagsOptions(tags: Array<Pick<PolicyTag, 'name' | 'enabled' | 'pendingAction'>>, selectedOptions?: SelectedTagOption[]): Option[] {
function getTagsOptions(tags: Array<Pick<PolicyTag, 'name' | 'enabled'>>, selectedOptions?: SelectedTagOption[]): Option[] {
return tags.map((tag) => {
// This is to remove unnecessary escaping backslash in tag name sent from backend.
const cleanedName = PolicyUtils.getCleanedTagName(tag.name);
Expand All @@ -1190,9 +1180,8 @@ function getTagsOptions(tags: Array<Pick<PolicyTag, 'name' | 'enabled' | 'pendin
keyForList: tag.name,
searchText: tag.name,
tooltipText: cleanedName,
isDisabled: !tag.enabled || tag.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
isDisabled: !tag.enabled,
isSelected: selectedOptions?.some((selectedTag) => selectedTag.name === tag.name),
pendingAction: tag.pendingAction,
};
});
}
Expand Down Expand Up @@ -1265,7 +1254,7 @@ function getTagListSections(
const filteredRecentlyUsedTags = recentlyUsedTags
.filter((recentlyUsedTag) => {
const tagObject = tags.find((tag) => tag.name === recentlyUsedTag);
return !!tagObject?.enabled && !selectedOptionNames.includes(recentlyUsedTag) && tagObject?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
return !!tagObject?.enabled && !selectedOptionNames.includes(recentlyUsedTag);
})
.map((tag) => ({name: tag, enabled: true}));

Expand Down Expand Up @@ -1395,15 +1384,14 @@ function sortTaxRates(taxRates: TaxRates): TaxRate[] {
* Builds the options for taxRates
*/
function getTaxRatesOptions(taxRates: Array<Partial<TaxRate>>): TaxRatesOption[] {
return taxRates.map(({code, modifiedName, isDisabled, isSelected, pendingAction}) => ({
return taxRates.map(({code, modifiedName, isDisabled, isSelected}) => ({
code,
text: modifiedName,
keyForList: modifiedName,
searchText: modifiedName,
tooltipText: modifiedName,
isDisabled: !!isDisabled || pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
isDisabled,
isSelected,
pendingAction,
}));
}

Expand Down
Loading
Loading