Skip to content

Fix Describe rule bugs - #104055

Merged
JS00001 merged 24 commits into
Expensify:mainfrom
rushatgabhane:rushat-describeRuleFixes
Oct 20, 2026
Merged

JS00001 merged 24 commits into
Expensify:mainfrom
rushatgabhane:rushat-describeRuleFixes

Conversation

@rushatgabhane

@rushatgabhane rushatgabhane commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Explanation of Change

Fixes the Describe bugs from QA, listed below.

Also adds Describe to the category tax rate editor.

Backend PRs:

Fixed Issues

$ #103859
$ #103872
$ #103930
$ #103928
$ #103863
$ #103869
PROPOSAL: #92743 (comment)

Tests

Steps 6 and 8 can only be tested after the backend PRs are deployed.

  1. Create a Control workspace with Rules enabled, the describeRule beta on, an Expensify Card with two cards, and a field requirement rule on the Advertising category.
  2. Go to Rules > Add rule > Set field requirements > Describe, enter "When category is Advertising, require a description", and tap Next.
  3. Verify the modal shows "That category already has a rule" and the form is not filled.
  4. Close the modal, tap Describe again, and verify the prompt is empty.
  5. Enter "Do not require receipt and require itemized receipt for Meals" and tap Next. Verify Receipt and Itemized receipt are both set to Require.
  6. Go back to Add rule > Restrict card spend > Describe, enter "Block retail purchases on all cards", and tap Next. Verify both cards are selected.
  7. On mWeb, tap Describe. Verify the Next button can be reached with the keyboard open.
  8. Go to Add rule > Apply expense defaults > Category > Describe, enter "Use the GST tax rate for Meals", and tap Next. Verify the category tax rule shows Meals and GST, not merchant fields.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests. Describe needs a connection, but the modal still opens empty while offline.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-10-15.at.02.39.39.mov
Screenshot 2026-10-15 at 02 35 50 Screenshot 2026-10-15 at 02 35 15 Screenshot 2026-10-15 at 02 34 02
Screen.Recording.2026-10-15.at.02.30.21.mov
Screen.Recording.2026-10-15.at.02.29.42.mov
Screen.Recording.2026-10-15.at.02.29.01.mov
Screen.Recording.2026-10-15.at.02.28.19.mov
Screen.Recording.2026-10-15.at.02.27.16.mov

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@melvin-bot

melvin-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx bun ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx bun ./scripts/generateTranslations.ts --compare-ref main

@rushatgabhane rushatgabhane changed the title Fix Describe rule bugs from QA Fix Describe rule bugs Oct 15, 2026
@rushatgabhane
rushatgabhane marked this pull request as ready for review October 15, 2026 00:46
@rushatgabhane
rushatgabhane requested review from a team as code owners October 15, 2026 00:46
@melvin-bot
melvin-bot Bot requested review from Krishna2323 and removed request for a team October 15, 2026 00:46
@melvin-bot

melvin-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

@Krishna2323 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]

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T01:05:36.918370Z 9bd0b96 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@melvin-bot
melvin-bot Bot requested review from joekaufmanexpensify and removed request for a team October 15, 2026 00:46
@rushatgabhane

Copy link
Copy Markdown
Member Author

@Krishna2323 Steps 6 and 8 can only be tested after the backend PRs are deployed.

But you can review the rest

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

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.

Files with missing lines Coverage Δ
src/CONST/index.ts 95.90% <ø> (ø)
src/libs/actions/Policy/Rules.ts 81.81% <100.00%> (+60.47%) ⬆️
...s/FlagForReviewRules/FlagForReviewRulePageBase.tsx 0.00% <ø> (ø)
...s/workspace/rules/SpendRules/SpendRuleCardPage.tsx 75.64% <100.00%> (+4.06%) ⬆️
src/styles/index.ts 66.22% <ø> (+0.88%) ⬆️
src/pages/workspace/rules/DescribeRuleModal.tsx 86.95% <95.00%> (+1.24%) ⬆️
...s/workspace/rules/SpendRules/SpendRulePageBase.tsx 0.00% <0.00%> (ø)
src/pages/workspace/rules/DescribeRuleButton.tsx 5.55% <0.00%> (-0.70%) ⬇️
...space/rules/MerchantRules/MerchantRulePageBase.tsx 62.77% <14.28%> (-1.41%) ⬇️
src/libs/SpendRulesUtils.ts 7.60% <52.94%> (+5.00%) ⬆️
... and 1 more
... and 541 files with indirect coverage changes

@joekaufmanexpensify joekaufmanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixing DBs

@yuwenmemon
yuwenmemon requested a review from JS00001 October 18, 2026 21:27
const generatedCategories = values.categories?.filter(isSpendRuleCategory);
setDraftSpendRule(generatedCategories ? {...values, categories: generatedCategories} : values);
const generatedCardIDs =
isAllCards && expensifyCardSettings ? getEligibleSpendRuleCards(cardsList, expensifyCardSettings).map((card) => String(card.cardID)) : spendRuleForm?.cardIDs;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When card settings haven't loaded yet (e.g. a deep link), an "all cards" answer quietly keeps the current selection instead. Do we think it's worth disabling Describe until expensifyCardSettings is loaded? Or the whole modal?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i don't think it is worth disabling.
the admin can choose the cards manually too

Comment thread tests/ui/SpendRuleCardPageTest.tsx Outdated
Comment thread src/libs/actions/Policy/Rules.ts
setDraftMerchantRule({...values, ruleType: CONST.POLICY.EXPENSE_DEFAULT_RULE_TYPE.MERCHANT});
const applyGeneratedRule = ({tax, ...values}: GeneratedRuleValues) => {
if (!isScopedToCategory) {
setDraftMerchantRule({...values, ruleType: CONST.POLICY.EXPENSE_DEFAULT_RULE_TYPE.MERCHANT});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tax is destructured out of the signature but only the category branch puts it back, so merchant rules lose it. Line 354 reads form?.tax for merchant rules. Does an expenseDefaults answer ever carry a tax?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

merchant rule doesn't have tax

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Merchant rules do have a tax field. Line 590 renders the tax row whenever hasUsableTaxRates(policy), line 639's filter keeps it, and line 354 reads form?.tax for merchant rules. Do you mean the backend never sends tax on an expenseDefaults answer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The backend doesn't send tax for an expenseDefaults rule. It only sends it for categoryTaxRate.

Comment thread src/pages/workspace/rules/SpendRules/SpendRulePageBase.tsx
Comment thread src/pages/workspace/rules/DescribeRuleModal.tsx
Comment thread src/pages/workspace/rules/DescribeRuleModal.tsx
Comment thread src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx
Comment thread src/libs/SpendRulesUtils.ts
Comment thread src/libs/SpendRulesUtils.ts
@Krishna2323

Krishna2323 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
  • Go to staging.new.expensify.com
  • Go to workspace settings > Rules.
  • Click Add rule > Set field requirements.
  • Click Describe.
  • Enter Do not require receipt and do require itemized receipt when Category is Advertising.
  • Click Next.
    → Receipt is set to Don't require. Itemized receipt is set to Require.
  • Click Save rule.
  • Go to Field requirements.
    → Both Receipt and Itemized receipt are set to Require.

#103928 @rushatgabhane this still fails:

Monosnap.screencast.2026-10-20.02-03-46.mp4

@Krishna2323

Copy link
Copy Markdown
Contributor

#103859 On android, the modal doesn't appear:

modal_doesn.t_appear.mp4

@rushatgabhane

rushatgabhane commented Oct 19, 2026 •

Copy link
Copy Markdown
Member Author

#104055 (comment)

this is not a valid bug. the instruction says "require itemized receipt", for which a receipt is required too.

@Krishna2323

Copy link
Copy Markdown
Contributor

@rushatgabhane Yeah correct, but it should throw error in that case? Currently it looks like the request was successful.

@rushatgabhane

rushatgabhane commented Oct 19, 2026 •

Copy link
Copy Markdown
Member Author

no why should it err? the intention of this feature is to do best effort for the user's request and transform it to a valid rule.

#103859 On android, the modal doesn't appear:

fixed, thanks!

@Krishna2323 Krishna2323 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@JS00001
JS00001 merged commit fa269ba into Expensify:main Oct 20, 2026
36 of 38 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 JS00001 has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/JS00001 in version: 9.5.15-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update is needed: every user-facing change in this PR is in the Describe rule flow, which only shows when the describeRule beta is on (DescribeRuleButton.tsx:51). The card filtering code that moved into SpendRulesUtils is a refactor and doesn't change behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants