Skip to content

feat: add auto-update government distance rates toggle - #97936

Open
Krishna2323 wants to merge 10 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue-95281
Open

feat: add auto-update government distance rates toggle#97936
Krishna2323 wants to merge 10 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue-95281

Conversation

@Krishna2323

@Krishna2323 Krishna2323 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #95281
PROPOSAL:

Tests

Prerequisites

  • A Control workspace where you're an admin, with Distance rates enabled under More features.
  • Workspace currency is USD
  1. Go to Workspace settings > Distance rates > Settings (RHP).
  2. Verify a new Auto-update government rate toggle appears above Track tax, off by default, with the copy "Automatically create new rates when the United States publishes new guidance. Doesn't modify existing rates." underneath.
  3. Turn the toggle on.
  4. Verify new rate appear immediately in Distance rates list > named like "2026 United States" and showing a lightning bolt icon.
  5. Hover the lightning bolt and verify the tooltip reads "This rate is auto-generated."
  6. Reload the page and verify the toggle is still on and the rates persist.
  7. Turn the toggle off, reload, and verify the toggle is off and the previously added government rates are still listed (they are not deleted).
  8. Turn the toggle back on and verify no duplicate rates are created — the rates already on the workspace are reused, not copied again.

Distance unit correction

  1. Change the workspace currency to CAD (Workspace settings > Overview > Default currency) and set Distance rates > Settings > Unit to Miles.
  2. Turn the auto-update toggle on.
  3. Verify the Unit row flips to Kilometers as part of the same save, and shows the greyed-out pending state until the response lands.

Unsupported currency

  1. Change the workspace currency to NZD (or any currency other than USD/CAD/GBP/AUD).
  2. Go to Distance rates > Settings and verify the Auto-update government rate toggle is not rendered.
  3. Change the currency back to USD and verify the toggle reappears.

Failure path

  1. Turn on "Simulate failing network requests", turn the toggle on
  2. Verify the toggle reverts to off, the optimistically added rates are removed, and a red error message appears under the toggle row.
  3. Dismiss the error with the X and verify it clears without changing the toggle state.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline.
  2. Turn the toggle on and verify the whole toggle row and the new rate rows show the greyed-out pending state.

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
    • MacOS: Desktop
  • 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 there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • 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 a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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_hybrid.mp4
Android: mWeb Chrome
android_mWeb.mp4
iOS: Native
ios_hybrid.mp4
iOS: mWeb Safari
ios_mWeb.mp4
MacOS: Chrome / Safari
web_chrome.mp4

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@melvin-bot

melvin-bot Bot commented Aug 6, 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 ts-node ./scripts/generateTranslations.ts --help

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

@melvin-bot

melvin-bot Bot commented Aug 16, 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

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323
Krishna2323 marked this pull request as ready for review August 16, 2026 15:34
@Krishna2323
Krishna2323 requested review from a team as code owners August 16, 2026 15:34
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and thelullabyy and removed request for a team, JmillsExpensify and thelullabyy August 16, 2026 15:34
@melvin-bot

melvin-bot Bot commented Aug 16, 2026

Copy link
Copy Markdown

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

Comment thread src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx Outdated
Signed-off-by: krishna2323 <belivethatkg@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: efc8505151

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@OSBotify

Copy link
Copy Markdown
Contributor

🦜 Polyglot Parrot! 🦜

Squawk! Looks like you added some shiny new English strings. Allow me to parrot them back to you in other tongues:

View the translation diff
diff --git a/src/languages/de.ts b/src/languages/de.ts
index 635638da..7cadc01d 100644
--- a/src/languages/de.ts
+++ b/src/languages/de.ts
@@ -7170,6 +7170,10 @@ Der Control-Tarif beginnt bei 9 $ pro aktivem Mitglied und Monat.`,
             startDate: 'Startdatum',
             endDate: 'Enddatum',
             autoGeneratedRateTooltip: 'Dieser Satz wurde automatisch erzeugt.',
+            autoUpdateGovernmentRate: 'Regierungssatz automatisch aktualisieren',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) =>
+                `Neue Steuersätze automatisch erstellen, wenn ${countryPhrase} neue Richtlinien veröffentlicht. Vorhandene Steuersätze werden nicht geändert.`,
+            governmentRateCountries: {US: 'die Vereinigten Staaten', CA: 'Kanada', GB: 'Großbritannien', AU: 'Australien'},
         },
         editor: {
             descriptionInputLabel: 'Beschreibung',
diff --git a/src/languages/el.ts b/src/languages/el.ts
index d90403cc..401add4d 100644
--- a/src/languages/el.ts
+++ b/src/languages/el.ts
@@ -7428,6 +7428,10 @@ _Για πιο αναλυτικές οδηγίες, [επισκεφθείτε τ
                 startDateMustBeBeforeEndDate: 'Η ημερομηνία έναρξης πρέπει να είναι πριν από την ημερομηνία λήξης',
             },
             autoGeneratedRateTooltip: 'Αυτός ο συντελεστής δημιουργείται αυτόματα.',
+            autoUpdateGovernmentRate: 'Αυτόματη ενημέρωση κρατικού συντελεστή',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) =>
+                `Δημιουργεί αυτόματα νέες τιμές όταν το ${countryPhrase} δημοσιεύει νέες οδηγίες. Δεν τροποποιεί τις υπάρχουσες τιμές.`,
+            governmentRateCountries: {US: 'οι Ηνωμένες Πολιτείες', CA: 'Καναδάς', GB: 'Μεγάλη Βρετανία', AU: 'Αυστραλία'},
         },
         editor: {
             descriptionInputLabel: 'Περιγραφή',
diff --git a/src/languages/es.ts b/src/languages/es.ts
index 154b2910..9b2c8ed0 100644
--- a/src/languages/es.ts
+++ b/src/languages/es.ts
@@ -7137,6 +7137,10 @@ El plan Controlar empieza en 9 $ por miembro activo al mes.`,
             startDate: 'Fecha de inicio',
             endDate: 'Fecha de fin',
             autoGeneratedRateTooltip: 'Esta tasa se genera automáticamente.',
+            autoUpdateGovernmentRate: 'Actualizar automáticamente la tasa gubernamental',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) =>
+                `Crea automáticamente nuevas tasas cuando ${countryPhrase} publique nuevas directrices. No modifica las tasas existentes.`,
+            governmentRateCountries: {US: 'Estados Unidos', CA: 'Canadá', GB: 'Gran Bretaña', AU: 'Australia'},
         },
         editor: {
             nameInputLabel: 'Nombre',
diff --git a/src/languages/fr.ts b/src/languages/fr.ts
index d5fb36e8..1182bf4c 100644
--- a/src/languages/fr.ts
+++ b/src/languages/fr.ts
@@ -7197,6 +7197,10 @@ Le forfait Control commence à 9 $ par Membre actif et par mois.`,
             startDate: 'Date de début',
             endDate: 'Date de fin',
             autoGeneratedRateTooltip: 'Ce taux est généré automatiquement.',
+            autoUpdateGovernmentRate: 'Mise à jour automatique du taux gouvernemental',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) =>
+                `Créer automatiquement de nouveaux taux lorsque ${countryPhrase} publie de nouvelles directives. Ne modifie pas les taux existants.`,
+            governmentRateCountries: {US: 'les États-Unis', CA: 'Canada', GB: 'Grande-Bretagne', AU: 'Australie'},
         },
         editor: {
             descriptionInputLabel: 'Description',
diff --git a/src/languages/it.ts b/src/languages/it.ts
index 8e1b563d..95e44db6 100644
--- a/src/languages/it.ts
+++ b/src/languages/it.ts
@@ -7141,6 +7141,10 @@ Il piano Control parte da 9 $ al mese per ogni membro attivo.`,
             startDate: 'Data di inizio',
             endDate: 'Data di fine',
             autoGeneratedRateTooltip: 'Questa tariffa è generata automaticamente.',
+            autoUpdateGovernmentRate: 'Aggiorna automaticamente tariffa governativa',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) =>
+                `Crea automaticamente nuove aliquote quando ${countryPhrase} pubblica nuove linee guida. Non modifica le aliquote esistenti.`,
+            governmentRateCountries: {US: 'gli Stati Uniti', CA: 'Canada', GB: 'Gran Bretagna', AU: 'Australia'},
         },
         editor: {
             descriptionInputLabel: 'Descrizione',
diff --git a/src/languages/ja.ts b/src/languages/ja.ts
index 283c302e..c0d7f9af 100644
--- a/src/languages/ja.ts
+++ b/src/languages/ja.ts
@@ -7059,6 +7059,10 @@ Control プランは、アクティブメンバー1人あたり月額 $9 から
             startDate: '開始日',
             endDate: '終了日',
             autoGeneratedRateTooltip: 'このレートは自動生成されています。',
+            autoUpdateGovernmentRate: '公定レートを自動更新',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) =>
+                `${countryPhrase} が新しいガイダンスを公開したときに、新しいレートを自動的に作成します。既存のレートは変更しません。`,
+            governmentRateCountries: {US: 'アメリカ合衆国', CA: 'カナダ', GB: 'グレートブリテン', AU: 'オーストラリア'},
         },
         editor: {
             descriptionInputLabel: '説明',
diff --git a/src/languages/nl.ts b/src/languages/nl.ts
index c313ee7d..8e697d00 100644
--- a/src/languages/nl.ts
+++ b/src/languages/nl.ts
@@ -7128,6 +7128,10 @@ Het Control-abonnement begint bij $9 per actieve deelnemer per maand.`,
             startDate: 'Startdatum',
             endDate: 'Einddatum',
             autoGeneratedRateTooltip: 'Dit tarief is automatisch gegenereerd.',
+            autoUpdateGovernmentRate: 'Automatische update overheidstarief',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) =>
+                `Maak automatisch nieuwe tarieven aan wanneer ${countryPhrase} nieuwe richtlijnen publiceert. Past bestaande tarieven niet aan.`,
+            governmentRateCountries: {US: 'de Verenigde Staten', CA: 'Canada', GB: 'Groot-Brittannië', AU: 'Australië'},
         },
         editor: {
             descriptionInputLabel: 'Beschrijving',
diff --git a/src/languages/pl.ts b/src/languages/pl.ts
index ad7bfa61..36261c79 100644
--- a/src/languages/pl.ts
+++ b/src/languages/pl.ts
@@ -7105,6 +7105,9 @@ Plan Control zaczyna się od 9 USD za aktywnego członka miesięcznie.`,
             startDate: 'Data rozpoczęcia',
             endDate: 'Data zakończenia',
             autoGeneratedRateTooltip: 'Ta stawka jest generowana automatycznie.',
+            autoUpdateGovernmentRate: 'Automatycznie aktualizuj stawkę rządową',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) => `Automatycznie twórz nowe stawki, gdy ${countryPhrase} publikuje nowe wytyczne. Nie zmienia istniejących stawek.`,
+            governmentRateCountries: {US: 'Stany Zjednoczone', CA: 'Kanada', GB: 'Wielka Brytania', AU: 'Australia'},
         },
         editor: {
             descriptionInputLabel: 'Opis',
diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts
index ebb23579..ad47c685 100644
--- a/src/languages/pt-BR.ts
+++ b/src/languages/pt-BR.ts
@@ -7127,6 +7127,10 @@ O plano Control começa em US$ 9 por membro ativo por mês.`,
             startDate: 'Data de início',
             endDate: 'Data de término',
             autoGeneratedRateTooltip: 'Essa tarifa é gerada automaticamente.',
+            autoUpdateGovernmentRate: 'Atualizar automaticamente a taxa governamental',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) =>
+                `Criar automaticamente novas taxas quando ${countryPhrase} publicar novas orientações. Não modifica as taxas existentes.`,
+            governmentRateCountries: {US: 'os Estados Unidos', CA: 'Canadá', GB: 'Reino Unido', AU: 'Austrália'},
         },
         editor: {
             descriptionInputLabel: 'Descrição',
diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts
index cbe4a0c5..437ddb2d 100644
--- a/src/languages/zh-hans.ts
+++ b/src/languages/zh-hans.ts
@@ -6890,6 +6890,9 @@ _如需更详细的说明,请[访问我们的帮助网站](${CONST.NETSUITE_IM
             startDate: '开始日期',
             endDate: '结束日期',
             autoGeneratedRateTooltip: '此费率为自动生成。',
+            autoUpdateGovernmentRate: '自动更新政府费率',
+            autoUpdateGovernmentRateDescription: (countryPhrase: string) => `当${countryPhrase}发布新指引时自动创建新税率。不会修改现有税率。`,
+            governmentRateCountries: {US: '美国', CA: '加拿大', GB: '大不列颠', AU: '澳大利亚'},
         },
         editor: {
             descriptionInputLabel: '描述',

Note

You can apply these changes to your branch by copying the patch to your clipboard, then running pbpaste | git apply 😉

View workflow run

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@codecov

codecov Bot commented Aug 17, 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 94.85% <ø> (ø)
src/ONYXKEYS.ts 100.00% <ø> (ø)
src/libs/API/types.ts 100.00% <ø> (ø)
src/libs/ExportOnyxState/common.ts 80.95% <ø> (+0.59%) ⬆️
src/libs/PolicyDistanceRatesUtils.ts 34.93% <100.00%> (+15.53%) ⬆️
.../distanceRates/PolicyDistanceRatesSettingsPage.tsx 0.00% <0.00%> (ø)
src/libs/actions/Policy/DistanceRate.ts 19.29% <0.00%> (-8.21%) ⬇️
... and 193 files with indirect coverage changes

@thelullabyy

Copy link
Copy Markdown
Contributor

@JmillsExpensify @MelvinBot Could you please assign me this issue? @MelvinBot removed me from the issue accidently

@MelvinBot

Copy link
Copy Markdown
Contributor

👋 Checked the linked issue Expensify/App#95281 — you (thelullabyy) are currently listed as an assignee there, alongside neil-marcellini and Krishna2323. So it looks like the assignment is already in place. If you're still seeing yourself as removed, try refreshing, and if it's still off please ping JmillsExpensify to re-add you (I don't have the ability to change issue assignees).

@thelullabyy

Copy link
Copy Markdown
Contributor

@MelvinBot You are able to do it, please assign me, I'm C+ for this issue/PR

@MelvinBot

Copy link
Copy Markdown
Contributor

✅ Done — I've added you (thelullabyy) as an assignee on this PR. You were already assigned on the linked issue Expensify/App#95281, so you're now assigned on both.

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.

5 participants