You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD] [$250] IOU - Stuck with "Category no longer valid" on confirm page after changing to a valid category #79902
Create an expense with Advertising category in self DM.
Go to workspace settings > Categories.
Delete Advertising category.
Go back to self DM.
Click Submit it to someone.
Select the workspace with deleted Advertising category.
On confirm page, enter merchant.
Click Create expense.
Click Category.
Change to any category.
On confirm page, click Create expense.
Expected Result:
Expense can be submitted to the workspace chat because category is now valid.
Actual Result:
"Category no longer valid" persists on confirm page after changing to a valid category.
User is stuck on confirm page. The expense cannot be submitted.
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
Restate the problem this issue is trying to solve.
After deleting a category and picking a valid one on the confirm page, submitting remains blocked with “Category no longer valid,” preventing expense submission.
What is the root cause of that problem?
formError stays set to violations.categoryOutOfPolicy; the submit handler exits early on this stale error instead of revalidating the current category (or other fields), so the corrected selection is never considered.
What changes do you think we should make in order to solve the problem?
Each submit attempt must validate only the current values.
Old errors must never block submit after inputs are fixed.
In MoneyRequestConfirmationList, inside the confirm callback:
Clear formError at the start.
Remove early returns that depend on old formError.
Always run validation on the latest data.
constconfirm=useCallback((paymentMethod: PaymentMethodType|undefined)=>{// Always start clean; downstream checks will set errors if neededsetFormError('');if(!!routeError||!transactionID){return;}if(iouType===CONST.IOU.TYPE.INVOICE&&!hasInvoicingDetails(policy)){Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_COMPANY_INFO.getRoute(iouType,transactionID,reportID,Navigation.getActiveRoute(),),);return;}
...
if(isEditingSplitBill&&areRequiredFieldsEmpty(transaction)){setDidConfirmSplit(true);setFormError('iou.error.genericSmartscanFailureMessage');return;}onConfirm?.(selectedParticipants);}else{if(!paymentMethod){return;}if(isDelegateAccessRestricted){showDelegateNoAccessModal();return;}Log.info(`[IOU] Sending money via: ${paymentMethod}`);onSendMoney?.(paymentMethod);}},[
...
],);
What alternative solutions did you explore? (Optional)
None
@Eskalifer1@ikevin127 Agree it stems from #79050, but the blocker isn’t the focus reset. The submit flow sets violations.categoryOutOfPolicy once, and when the user picks a valid category we never clear/revalidate that error. The confirm handler bails early on the stale formError, so the new category is never considered. We should clear or recompute formError on category change (or at the start of submit) so only current values are validated. Thanks
Hi! Coming from #80192 as my problem has the same root cause. I agree with @yatin-italy - that
The submit flow sets violations.categoryOutOfPolicy once, and when the user picks a valid category we never clear/revalidate that error.
I also thought of clearing the error when submitting the for as @yatin-italy suggests, but it would mean showing the violations after changing the value. I see that some fields like merchant are cleared right after changing - I think it happens because of this condition
Merchant field violation is 'iou.error.invalidMerchant' so it passes the condition. But it means that we have very inconsistent error clearing. After introducing the fix we would still clear all the errors starting with 'iou' and these ones with 'violation' prefix would persist but won't block the confirmation. We unfortunately have these inconsistencies even for the single fields like categories or tags (look at the screenshots below).
also the current implementation clears the violation for merchant even if the field wasn't properly filled in.
Screen.Recording.2026-01-22.at.15.21.13.mp4
We could possibly clear all these violations on regaining focus, but I don't think it's the best option.
Yet another thing to consider: the validation flow is showing only one validation at a time - I had mentioned while working on tags:
So you only see the validation for the Category, Tags or Taxes field only when the merchant field and the subsequent are filled in. This is also imho not very user friendly. We should have all the errors shown at once.
Screen.Recording.2025-11-05.at.17.30.51.mp4
I think this whole validation flow should be rebuild - most importantly - the error being cleared when the correct value is provided. Showing all the violations at once can be done at the same time or not - up to your decision.
To double-check: is it or not a regression from my PR ? Just want to confirm as I have a follow-up PR open and can add the fix there if confirmed from my PR.
@parasharrajat no, it needs to be a FE fix - we don't send the transaction values to the BE every time we change it. We should deal with it locally. BE is only responsible for violations after the request for submitting the expense/creating one is sent.
@ikevin127 If I did it correctly I haven't noticed that reverting one particular commit from your PR fixed the issue. But I'll double check and let you know. But strangely - we worked on category field long time ago - so such problem should be catched much earlier. While working on Tags field that also use "violation." prefixed error, I also don't remember having a problem with that.
I already have an easy solution on my mind that I will test and if it works I'll post my findings.
@ikevin127 I double checked and I confirm - the change from your PR caused the problem. The exact part @Eskalifer1 mentioned here. I left a comment in your PR.
Screen.Recording.2026-01-23.at.09.31.07.mp4
So if you still have your follow-up PR opened, please add a fix.
Still I think clearing form error on focus is not the best solution (see the recording that the error is cleared even if the proper value is not selected), but we can revert to it for now and think of a better solution later.
Reacted by Jayesh Mangwani, parasharrajat and Yatin Twinkle
So if you still have your follow-up PR opened, please add a fix.
🔄 Working on adding a solution that would resolve both this issue and maintain the fix for the other regression issue which prompted the addition of the non-optimal code in the first place.
The regression was introduced in PR #79050 - the useEffect preserves violations.* prefixed errors on focus changes but only missingAttendees has clearing logic - other violations (categoryOutOfPolicy, tagOutOfPolicy, taxOutOfPolicy) are never cleared when the user corrects the data.
Solution
Create a single reusable function that maps violation names to their respective validation logic. This approach:
Eliminates code duplication - All violation clearing uses the same pattern
Is easily extensible - Adding new violations is just adding an entry to the map
Centralizes validation logic - Makes it clear what each violation checks
Important
This solution maintains the original fix for the attendee issue (#79013) while providing a clean, extensible pattern for all violation types (resolving this issue).
Add a helper function:
/** * Checks if a violation has been fixed by the user changing the underlying data. * Returns true if the violation should be cleared, false if it should persist. */constgetIsViolationFixed=(violationError: string): boolean=>{consttransactionTag=getTag(transaction);constviolationValidators: Record<string,()=>boolean>={'violations.categoryOutOfPolicy': ()=>{// Category is fixed if it exists and is enabled in policyreturn!!(iouCategory&&policyCategories?.[iouCategory]?.enabled);},'violations.tagOutOfPolicy': ()=>{// Tag is fixed if it's empty or matches a valid tag in policyreturn!transactionTag||(hasEnabledTags(policyTagLists)&&hasMatchingTag(policyTags,transactionTag));},'violations.taxOutOfPolicy': ()=>{// Tax is fixed if it's empty or exists in policy tax ratesreturn!transaction?.taxCode||Object.keys(policy?.taxRates?.taxes??{}).some((key)=>key===transaction?.taxCode);},'violations.missingAttendees': ()=>{// Attendees violation is fixed if attendees requirement is now satisfiedreturn!getIsMissingAttendeesViolation(policyCategories,iouCategory,iouAttendees,currentUserPersonalDetails,policy?.isAttendeeTrackingEnabled);},};constvalidator=violationValidators[violationError];returnvalidator ? validator() : false;};
Simplify the useEffect:
useEffect(()=>{if(shouldDisplayFieldError&&didConfirmSplit){setFormError('iou.error.genericSmartscanFailureMessage');return;}if(shouldDisplayFieldError&&hasSmartScanFailed){setFormError('iou.receiptScanningFailed');return;}// Reset the form error whenever the screen gains or loses focus// but preserve violation-related errors since those represent real validation issues// that can only be fixed by changing the underlying dataif(!formError.startsWith(CONST.VIOLATIONS_PREFIX)){setFormError('');return;}// Clear any violation error if the user has fixed the underlying dataif(getIsViolationFixed(formError)){setFormError('');}// eslint-disable-next-line react-hooks/exhaustive-deps -- we don't want this effect to run if it's just setFormError that changes},[isFocused,shouldDisplayFieldError,hasSmartScanFailed,didConfirmSplit,getIsViolationFixed,formError]);
Summary of Changes
Before
After
4 separate if-blocks checking individual violations
1 reusable function with a validation map
Adding new violation = copy-paste + modify
Adding new violation = add 1 entry to map
Hard to test individual validators
Easy to unit test getIsViolationFixed
Logic scattered in useEffect
Logic centralized in function
🟢 Benefits
DRY (Don't Repeat Yourself): Single pattern handles all violations
Open/Closed Principle: Open for extension (add entries), closed for modification (don't touch the useEffect)
Testable: The getIsViolationFixed function can be easily unit tested
Self-documenting: The map clearly shows what each violation checks
Future-proof: When new violations are added, just add an entry to the map
changed the title [-][$250] IOU - Stuck with "Category no longer valid" on confirm page after changing to a valid category[/-][+][HOLD] [$250] IOU - Stuck with "Category no longer valid" on confirm page after changing to a valid category[/+]on Jan 24, 2026
Activity
melvin-bot commentedon Jan 19, 2026
Triggered auto assignment to @mallenexpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.etCoderDysto commentedon Jan 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Stuck with "Category no longer valid" on confirm page after changing to a valid category
What is the root cause of that problem?
We are not clearing categoryOutOfPolicy formError when category changes here
App/src/components/MoneyRequestConfirmationList.tsx
Lines 447 to 450 in 7588135
What changes do you think we should make in order to solve the problem?
We should clear categoryOutOfPolicy error when there is change in category.
We can use clearFormErrors instead of setFormError.
What alternative solutions did you explore? (Optional)
We can create a separete useEffect like below and remove violations when only moving expense form DM to workspace
App/src/components/MoneyRequestConfirmationList.tsx
Lines 452 to 459 in 6fa8428
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
yatin-italy commentedon Jan 19, 2026
Proposal
Restate the problem this issue is trying to solve.
After deleting a category and picking a valid one on the confirm page, submitting remains blocked with “Category no longer valid,” preventing expense submission.
What is the root cause of that problem?
formError stays set to violations.categoryOutOfPolicy; the submit handler exits early on this stale error instead of revalidating the current category (or other fields), so the corrected selection is never considered.
What changes do you think we should make in order to solve the problem?
In
MoneyRequestConfirmationList, inside the confirm callback:formErrorat the start.formError.What alternative solutions did you explore? (Optional)
None
Eskalifer1 commentedon Jan 19, 2026
Hi @ikevin127, seems like this is regression from #79050, especially this part:
App/src/components/MoneyRequestConfirmationList.tsx
Lines 446 to 452 in f6e1833
yatin-italy commentedon Jan 19, 2026
@Eskalifer1 @ikevin127 Agree it stems from #79050, but the blocker isn’t the focus reset. The submit flow sets violations.categoryOutOfPolicy once, and when the user picks a valid category we never clear/revalidate that error. The confirm handler bails early on the stale formError, so the new category is never considered. We should clear or recompute formError on category change (or at the start of submit) so only current values are validated. Thanks
koko57 commentedon Jan 22, 2026
Hi! Coming from #80192 as my problem has the same root cause. I agree with @yatin-italy - that
I also thought of clearing the error when submitting the for as @yatin-italy suggests, but it would mean showing the violations after changing the value. I see that some fields like merchant are cleared right after changing - I think it happens because of this condition
App/src/components/MoneyRequestConfirmationList.tsx
Lines 446 to 452 in f6e1833
Merchant field violation is 'iou.error.invalidMerchant' so it passes the condition. But it means that we have very inconsistent error clearing. After introducing the fix we would still clear all the errors starting with 'iou' and these ones with 'violation' prefix would persist but won't block the confirmation. We unfortunately have these inconsistencies even for the single fields like categories or tags (look at the screenshots below).
also the current implementation clears the violation for merchant even if the field wasn't properly filled in.
Screen.Recording.2026-01-22.at.15.21.13.mp4
We could possibly clear all these violations on regaining focus, but I don't think it's the best option.
Yet another thing to consider: the validation flow is showing only one validation at a time - I had mentioned while working on tags:
So you only see the validation for the Category, Tags or Taxes field only when the merchant field and the subsequent are filled in. This is also imho not very user friendly. We should have all the errors shown at once.
Screen.Recording.2025-11-05.at.17.30.51.mp4
I think this whole validation flow should be rebuild - most importantly - the error being cleared when the correct value is provided. Showing all the violations at once can be done at the same time or not - up to your decision.
cc @cristipaval @parasharrajat
parasharrajat commentedon Jan 22, 2026
We need backend changes to show all violations at a time. I also think we should do that....
@cristipaval What is the cost of making that change in the backend? Can you please discuss this internally and see if this is something we should do?
ikevin127 commentedon Jan 22, 2026
To double-check: is it or not a regression from my PR ? Just want to confirm as I have a follow-up PR open and can add the fix there if confirmed from my PR.
koko57 commentedon Jan 23, 2026
@parasharrajat no, it needs to be a FE fix - we don't send the transaction values to the BE every time we change it. We should deal with it locally. BE is only responsible for violations after the request for submitting the expense/creating one is sent.
@ikevin127 If I did it correctly I haven't noticed that reverting one particular commit from your PR fixed the issue. But I'll double check and let you know. But strangely - we worked on category field long time ago - so such problem should be catched much earlier. While working on Tags field that also use "violation." prefixed error, I also don't remember having a problem with that.
I already have an easy solution on my mind that I will test and if it works I'll post my findings.
koko57 commentedon Jan 23, 2026
@ikevin127 I double checked and I confirm - the change from your PR caused the problem. The exact part @Eskalifer1 mentioned here. I left a comment in your PR.
Screen.Recording.2026-01-23.at.09.31.07.mp4
So if you still have your follow-up PR opened, please add a fix.
Still I think clearing form error on focus is not the best solution (see the recording that the error is cleared even if the proper value is not selected), but we can revert to it for now and think of a better solution later.
7 remaining items
ikevin127 commentedon Jan 24, 2026
🔄 Working on adding a solution that would resolve both this issue and maintain the fix for the other regression issue which prompted the addition of the non-optimal code in the first place.
ikevin127 commentedon Jan 24, 2026
Root Cause
The regression was introduced in PR
#79050- theuseEffectpreservesviolations.*prefixed errors on focus changes but onlymissingAttendeeshas clearing logic - other violations (categoryOutOfPolicy,tagOutOfPolicy,taxOutOfPolicy) are never cleared when the user corrects the data.Solution
Create a single reusable function that maps violation names to their respective validation logic. This approach:
Important
This solution maintains the original fix for the attendee issue (
#79013) while providing a clean, extensible pattern for all violation types (resolving this issue).useEffect:Summary of Changes
getIsViolationFixeduseEffect🟢 Benefits
useEffect)getIsViolationFixedfunction can be easily unit testedikevin127 commentedon Jan 24, 2026
✅ Issue addressed as per ☝️ proposal, fix added to existing follow-up PR #79741, commit a0b5705.
@cristipaval @mallenexpensify Please put this issue on [HOLD] for the above-mentioned PR, it should get merged soon and have this issue fixed 🙌
[-][$250] IOU - Stuck with "Category no longer valid" on confirm page after changing to a valid category[/-][+][HOLD] [$250] IOU - Stuck with "Category no longer valid" on confirm page after changing to a valid category[/+]cristipaval commentedon Jan 24, 2026
Thanks @ikevin127! HOLD added
m-natarajan commentedon Jan 27, 2026
@cristipaval Similar issue reported here as well
cristipaval commentedon Jan 27, 2026
The PR that fixes this got merged.
mallenexpensify commentedon Jan 27, 2026
Requested retest, thanks @cristipaval
m-natarajan commentedon Jan 27, 2026
Issue is not reproducible on Windows 11/ Chrome in v9.3.10-1
79902.mp4
mallenexpensify commentedon Jan 27, 2026
Closing, thanks @m-natarajan