-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix: changing from type:chat to type:expense, has:link is not removed #79727
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| updatedFilterFormValues.columns = []; | ||
| updatedFilterFormValues.status = CONST.SEARCH.STATUS.EXPENSE.ALL; | ||
| // Filter out invalid "has" values for the new type | ||
| if (updatedFilterFormValues.has && updatedFilterFormValues.type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CONSISTENCY-3 (docs)
The logic for filtering invalid "has" values is duplicated in both SearchFiltersBar.tsx and SearchFiltersTypePage.tsx. This increases maintenance overhead and raises bug risk.
Suggested fix: Extract this logic into a reusable utility function:
// In SearchUIUtils.ts or a new utility file
function filterValidHasValues(
hasValues: string[] | undefined,
type: SearchDataTypes,
translate: LocalizedTranslate
): string[] | undefined {
if (\!hasValues || \!type) return undefined;
const validHasOptions = getHasOptions(translate, type);
const validHasValues = new Set(validHasOptions.map((option) => option.value));
const filteredHasValues = hasValues.filter((hasValue) =>
validHasValues.has(hasValue as ValueOf<typeof CONST.SEARCH.HAS_VALUES>)
);
return filteredHasValues.length > 0 ? filteredHasValues : undefined;
}Then use it in both locations:
updatedFilterFormValues.has = filterValidHasValues(
updatedFilterFormValues.has,
updatedFilterFormValues.type,
translate
);|
|
||
| const applyChanges = useCallback(() => { | ||
| const hasTypeChanged = selectedItem !== searchAdvancedFiltersForm?.type; | ||
| const validHasOptions = getHasOptions(translate, selectedItem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CONSISTENCY-3 (docs)
The logic for filtering invalid "has" values is duplicated from SearchFiltersBar.tsx. This increases maintenance overhead and raises bug risk.
Suggested fix: Extract this logic into a reusable utility function (see comment in SearchFiltersBar.tsx) and use it here:
const filteredHasValues = filterValidHasValues(
searchAdvancedFiltersForm?.has,
selectedItem,
translate
);
const updatedFilters = {
type: selectedItem,
...(hasTypeChanged && {
groupBy: null,
status: CONST.SEARCH.STATUS.EXPENSE.ALL,
has: filteredHasValues,
}),
};
Explanation of Change
Fixed Issues
$ #77629
PROPOSAL: #77629 (comment)
Tests
has:linkis removedOffline tests
Same as tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android.mov
Android: mWeb Chrome
android-mweb.mov
iOS: Native
ios.mov
iOS: mWeb Safari
ios-mweb.mov
MacOS: Chrome / Safari
we.mov