[No QA][Part 3f] Pass policyTags through BrowserNotifications modified-expense chain#84029
Conversation
|
@parasharrajat 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] |
| import EXPENSIFY_ICON_URL from '@assets/images/expensify-logo-round-clearspace.png'; | ||
| import * as AppUpdate from '@libs/actions/AppUpdate'; | ||
| import {getForReportAction} from '@libs/ModifiedExpenseMessage'; | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated |
There was a problem hiding this comment.
❌ CONSISTENCY-5 (docs)
The // eslint-disable-next-line @typescript-eslint/no-deprecated comment on the translateLocal import lacks an accompanying justification explaining why the deprecated API is being used.
Add a reason comment, e.g.:
// eslint-disable-next-line @typescript-eslint/no-deprecated -- translateLocal is used until Localize module is migrated off deprecated API
import {translateLocal} from '@libs/Localize';Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
src/libs/ReportNameUtils.ts
Outdated
| report: Report | undefined, | ||
| reportPolicy: Policy | undefined, | ||
| parentReport: Report | undefined, | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars |
There was a problem hiding this comment.
❌ CONSISTENCY-5 (docs)
The // eslint-disable-next-line @typescript-eslint/no-unused-vars disable on the _policyTags parameter lacks a justification comment explaining why an unused parameter is being added to this function signature.
Add a reason, e.g.:
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- policyTags will be used once modified expense message migration is complete
_policyTags?: OnyxEntry<PolicyTagLists>,Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
src/libs/ReportNameUtils.ts
Outdated
| reportPolicy: Policy | undefined, | ||
| parentReport: Report | undefined, | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| _policyTags?: OnyxEntry<PolicyTagLists>, |
There was a problem hiding this comment.
❌ CONSISTENCY-4 (docs)
The _policyTags parameter is added to computeReportNameBasedOnReportAction but is immediately marked as unused. This is dead code — the parameter is threaded through callers (computeReportName) and adds to the function's surface area without being consumed.
Either use the parameter in this function's implementation (if there is a modified-expense code path that should use it) or remove it until it is actually needed. Passing policyTags only to computeChatThreadReportName does not require adding it to computeReportNameBasedOnReportAction.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| movedToReport, | ||
| policyTags, | ||
| currentUserLogin: '', | ||
| }) |
There was a problem hiding this comment.
❌ CONSISTENCY-2 (docs)
Passing currentUserLogin: '' as a hardcoded empty string defeats the purpose of the currentUserLogin parameter. Inside getForReportActionTemp, an empty string will always trigger the fallback to storedCurrentUserLogin, so this parameter serves no function here.
Either thread the actual currentUserLogin value through computeChatThreadReportName, or if the fallback behavior is intentional, add a comment explaining why:
// currentUserLogin is not available in this context; getForReportActionTemp falls back to storedCurrentUserLogin
currentUserLogin: '',Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3376483bba
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
src/libs/ReportNameUtils.ts
Outdated
| ? getForReportActionTemp({ | ||
| translate, | ||
| reportAction: parentReportAction, | ||
| movedFromReport, | ||
| movedToReport, | ||
| policyTags, | ||
| currentUserLogin: '', |
There was a problem hiding this comment.
Pass policy into temp modified-expense formatter
When policyTags is present, this branch calls getForReportActionTemp() without a policy, but that formatter needs policy.id/admin context to render policy-rule and MCC-based modified-expense messages correctly. In modified-expense threads where originalMessage contains policyRulesModifiedFields (or MCC-sourced category changes), the report name can degrade to a generic/less accurate message because getForReportActionTemp cannot build the rule-specific output without policy.
Useful? React with 👍 / 👎.
3376483 to
291c22f
Compare
291c22f to
6dd11ff
Compare
…yTags to computeReportName Wire POLICY_TAGS into the reportAttributes OnyxDerived config so per-report policy tags are available at derivation time and forwarded to computeReportName. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6dd11ff to
d330595
Compare
…ified expenses Wire policyTags, policy, and currentUserLogin through showReportActionNotification → showModifiedExpenseNotification → pushModifiedExpenseNotification so the notification body can use the non-Onyx.connect path (getForReportActionTemp) when policy tags are available, while falling back to the old getForReportAction otherwise. Add module-level allPolicies and allPolicyTags Onyx connections to Report/index.ts following the same pattern as the existing allReports connection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d330595 to
cd86c19
Compare
|
No product review needed |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd86c19eda
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| ONYXKEYS.SESSION, | ||
| ONYXKEYS.COLLECTION.POLICY, | ||
| ONYXKEYS.COLLECTION.POLICY_TAGS, |
There was a problem hiding this comment.
Recompute derived report names on policy tag changes
Adding ONYXKEYS.COLLECTION.POLICY_TAGS as a dependency here makes policy-tag updates call this compute function, but the incremental path only treats report/reportAction/reportName/transaction updates as actionable. Once isFullyComputed is true, a POLICY_TAGS-only update returns currentValue unchanged, so modified-expense thread names can keep stale tag-list labels until an unrelated report or transaction update happens.
Useful? React with 👍 / 👎.
| reportAction, | ||
| policyID: report.policyID, | ||
| movedFromReport, | ||
| movedToReport, | ||
| }); |
There was a problem hiding this comment.
Pass current user login into legacy modified-expense fallback
When policyTags is unavailable (for example, before the tag collection is hydrated), this fallback now calls getForReportAction without currentUserLogin even though the caller provides it. In that case the formatter falls back to its module-level cached login, which can be empty/stale during startup or session transitions, causing admin-dependent MCC modified-expense notification text/links to be rendered incorrectly.
Useful? React with 👍 / 👎.
src/libs/actions/Report/index.ts
Outdated
| let allPolicies: OnyxCollection<Policy>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.POLICY, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
| allPolicies = value; | ||
| }, | ||
| }); | ||
|
|
||
| let allPolicyTags: OnyxCollection<PolicyTagLists>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.POLICY_TAGS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
| allPolicyTags = value; | ||
| }, | ||
| }); | ||
|
|
There was a problem hiding this comment.
Can you move these subscriptions to the notification lib so that we can keep them at one place?
There was a problem hiding this comment.
This was done intentionally per the internal task spec by @kubabutkiewicz, which explicitly suggests using a module-level Onyx connection in Report/index.ts as the preferred approach for this non-React context - since the file already follows this pattern with allReports and others.
In showReportActionNotification (Report/index.ts:3593): resolve policyTags from the report's policyID — since this is a non-React context, either:
- Use a module-level Onyx connection for policyTags in Report/index.ts (this file already has module-level allReports)
- Or use Onyx.get() if async is acceptable at that point
As I understand, the PR is a deliberate intermediate step - BrowserNotifications.ts is already clean, and Report/index.ts will follow as part of the wider migration.
If the above assumption is wrong, let me know.
cc: @kubabutkiewicz
There was a problem hiding this comment.
We are removing subscriptions from the report/index file as well. Since the Notification module lives in js layer, it is fine to pass ONyx values via local subscription but it is better to move the subscriptions to lower-level libs so that they all live in single module.
BUT, I think we can refactor this wrapper function as well to pass down values from a component. It can be done in next PRs.
There was a problem hiding this comment.
Report/index.ts will follow as part of the wider migration.
Yes, but as per the guidelines of this refactoring, we have to refactor down to the component level so that we don't increase the work for others. So we can create a new PR for this if needed.
There was a problem hiding this comment.
I'm fine with this as long as they are only here temporarily for the refactoring. In order to make this clear, please add code comments that explain:
- Why the code is there
- When it will be removed
- Link to the specific refactoring issue
That will keep others from seeing it and copying it by mistake.
There was a problem hiding this comment.
Moved the subscriptions to the notification lib. Tell me what you think.
…ions-chain Adapt computeReportName call to upstream's object-param refactoring (ComputeReportName type); keep allPolicyTags wired in. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| BrowserNotifications.pushReportCommentNotification(report, reportAction, onClick, conciergeReportID, true); | ||
| let allPolicies: OnyxCollection<Policy>; | ||
| // eslint-disable-next-line rulesdir/no-onyx-connect -- temporary subscription for modified-expense notification; see https://github.com/Expensify/App/issues/66336 | ||
| Onyx.connect({ |
There was a problem hiding this comment.
| Onyx.connect({ | |
| Onyx.connectWithoutView({ |
|
|
||
| let allPolicyTags: OnyxCollection<PolicyTagLists>; | ||
| // eslint-disable-next-line rulesdir/no-onyx-connect -- temporary subscription for modified-expense notification; see https://github.com/Expensify/App/issues/66336 | ||
| Onyx.connect({ |
| ? getForReportActionTemp({ | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated -- translateLocal is deprecated; BrowserNotifications is non-React code that cannot use the translate hook | ||
| translate: translateLocal, | ||
| reportAction, | ||
| policy, | ||
| movedFromReport, | ||
| movedToReport, | ||
| policyTags, | ||
| currentUserLogin, | ||
| }) | ||
| : getForReportAction({ |
There was a problem hiding this comment.
We recently refactored these functions so let's verify that are passing all params.
…-connect-browsernotifications-chain # Conflicts: # src/libs/Notification/LocalNotification/index.ts
…calNotification Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tgolen
left a comment
There was a problem hiding this comment.
I approve, but please make the update to use Onyx.connectWithoutView()
…tionTemp Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ndex.ts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…cation/index.ts" This reverts commit 4d024bc.
62211f2 to
b6446ae
Compare
|
I will run the checklist on this shortly just waiting for some changes to be merged in main so that I can verify the updates here. |
parasharrajat
left a comment
There was a problem hiding this comment.
Reviewer Checklist
- I have verified the author checklist is complete (all boxes are checked off).
- I verified the correct issue is linked in the
### Fixed Issuessection above - I verified testing steps are clear and they cover the changes made in this PR
- I verified the steps for local testing are in the
Testssection - I verified the steps for Staging and/or Production testing are in the
QA stepssection - I verified the steps cover any possible 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 verified the steps for local testing are in the
- I checked that screenshots or videos are included for tests on all platforms
- I included screenshots or videos for tests on all platforms
- I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
- I verified tests pass on all platforms & I tested again on:
- Android: HybridApp
- Android: mWeb Chrome
- iOS: HybridApp
- iOS: mWeb Safari
- MacOS: Chrome / Safari
- If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- I verified proper code patterns were followed (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.
toggleReportand notonIconClick). - 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 - 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
- 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.
- If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- I verified that this PR follows the guidelines as stated in the Review Guidelines
- I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like
Avatar, I verified the components usingAvatarhave been tested & I retested again) - 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
- If a new component is created I verified that:
- A similar component doesn't exist in the codebase
- All props are defined accurately and each prop has a
/** comment above it */ - The file is named correctly
- The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- The only data being stored in the state is data necessary for rendering and nothing else
- For Class Components, any internal methods passed to components event handlers are bound to
thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor) - Any internal methods bound to
thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick) - All JSX used for rendering exists in the render method
- The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- 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 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
Avataris modified, I verified thatAvataris 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
Designlabel and/or tagged@Expensify/designso the design team can review the changes.
- If a new page is added, I verified it's using the
ScrollViewcomponent to make it scrollable when more elements are added to the page. - For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
- If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
🎀 👀 🎀 C+ reviewed
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #66336 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
|
🚧 @tgolen has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/tgolen in version: 9.3.39-0 🚀
|
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.3.39-3 🚀
|
Explanation of Change
Threads
policyTagsandpolicyexplicitly through the browser notification chain for modified expenses, removing the module-levelOnyx.connectsubscription fromModifiedExpenseMessage.LocalNotificationModifiedExpenseParamsgainspolicyTags: OnyxEntry<PolicyTagLists>andpolicy: OnyxEntry<Policy>fieldsshowModifiedExpenseNotificationinLocalNotification/index.tsforwards those fields toBrowserNotifications.pushModifiedExpenseNotificationBrowserNotifications.pushModifiedExpenseNotificationpasses them togetForReportActionTempinstead of relying on a module-level Onyx subscriptionReport/index.tsresolves and passes the correct per-report values when callingshowModifiedExpenseNotificationThis PR is part of the work split from #75562.
Fixed Issues
$#66336
PROPOSAL:
Tests
Offline tests
N/A — pure refactor, no network calls added or removed.
QA Steps
[No QA] — no user-visible behavior change. This is a pure internal refactor.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand 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
N/A — no UI changes
Android: mWeb Chrome
N/A — no UI changes
iOS: Native
N/A — no UI changes
iOS: mWeb Safari
N/A — no UI changes
MacOS: Chrome / Safari
N/A — no UI changes