-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: migrate ReportActionItem to useOnyx for policyTags #80258
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
Changes from all commits
72762ce
d0ff5e2
58e8860
b728cbe
0821bd1
f8f7357
128592e
14255aa
acb30b7
be64c7f
e1ee69b
a2dceaf
d651e7f
feb6990
0bd9a8d
cbec8b1
0515fda
7d18ddb
30b188a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ import {getPolicyName, getReportName, getRootParentReport, isPolicyExpenseChat, | |
| import {getFormattedAttendees, getTagArrayFromName} from './TransactionUtils'; | ||
|
|
||
| let allPolicyTags: OnyxCollection<PolicyTagLists> = {}; | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated -- Onyx.connectWithoutView is being removed in https://github.com/Expensify/App/issues/66336 | ||
| Onyx.connectWithoutView({ | ||
| key: ONYXKEYS.COLLECTION.POLICY_TAGS, | ||
| waitForCollectionCallback: true, | ||
|
|
@@ -43,15 +44,16 @@ Onyx.connectWithoutView({ | |
| let environmentURL: string; | ||
| getEnvironmentURL().then((url: string) => (environmentURL = url)); | ||
|
|
||
| let currentUserLogin = ''; | ||
| let storedCurrentUserLogin = ''; | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated -- Onyx.connectWithoutView is being removed in https://github.com/Expensify/App/issues/66336 | ||
| Onyx.connectWithoutView({ | ||
| key: ONYXKEYS.SESSION, | ||
| callback: (value) => { | ||
| // When signed out, value is undefined | ||
| if (!value) { | ||
| return; | ||
| } | ||
| currentUserLogin = value?.email ?? ''; | ||
| storedCurrentUserLogin = value?.email ?? ''; | ||
| }, | ||
| }); | ||
|
|
||
|
|
@@ -164,7 +166,7 @@ function getForExpenseMovedFromSelfDM(translate: LocalizedTranslate, destination | |
| // In NewDot, the "Move report" flow only supports moving expenses from self-DM to: | ||
| // - A policy expense chat | ||
| // - A 1:1 DM | ||
| const currentUserAccountID = getPersonalDetailByEmail(currentUserLogin)?.accountID; | ||
| const currentUserAccountID = getPersonalDetailByEmail(storedCurrentUserLogin)?.accountID; | ||
| const reportName = isPolicyExpenseChat(rootParentReport) | ||
| ? getPolicyExpenseChatName({report: rootParentReport}) | ||
| : buildReportNameFromParticipantNames({report: rootParentReport, currentUserAccountID}); | ||
|
|
@@ -330,7 +332,7 @@ function getForReportAction({ | |
| } else if (reportActionOriginalMessage?.source === CONST.CATEGORY_SOURCE.MCC) { | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| const policy = getPolicy(policyID); | ||
| const isAdmin = isPolicyAdmin(policy, currentUserLogin); | ||
| const isAdmin = isPolicyAdmin(policy, storedCurrentUserLogin); | ||
|
|
||
| // For admins, create a hyperlink to the workspace rules page | ||
| if (isAdmin && policy?.id) { | ||
|
|
@@ -514,13 +516,15 @@ function getForReportActionTemp({ | |
| movedFromReport, | ||
| movedToReport, | ||
| policyTags, | ||
| currentUserLogin, | ||
| }: { | ||
| translate: LocalizedTranslate; | ||
| reportAction: OnyxEntry<ReportAction>; | ||
| policy?: OnyxEntry<Policy>; | ||
| movedFromReport?: OnyxEntry<Report>; | ||
| movedToReport?: OnyxEntry<Report>; | ||
| policyTags: OnyxEntry<PolicyTagLists>; | ||
| currentUserLogin: string; | ||
| }): string { | ||
| if (!isModifiedExpenseAction(reportAction)) { | ||
| return ''; | ||
|
|
@@ -693,30 +697,17 @@ function getForReportActionTemp({ | |
|
|
||
| const hasModifiedBillable = isReportActionOriginalMessageAnObject && 'oldBillable' in reportActionOriginalMessage && 'billable' in reportActionOriginalMessage; | ||
| if (hasModifiedBillable) { | ||
| buildMessageFragmentForValue( | ||
| translate, | ||
| reportActionOriginalMessage?.billable ?? '', | ||
| reportActionOriginalMessage?.oldBillable ?? '', | ||
| translate('iou.expense'), | ||
| true, | ||
| setFragments, | ||
| removalFragments, | ||
| changeFragments, | ||
| ); | ||
| const oldBillable = reportActionOriginalMessage?.oldBillable === 'billable' ? translate('common.billable').toLowerCase() : translate('common.nonBillable').toLowerCase(); | ||
| const newBillable = reportActionOriginalMessage?.billable === 'billable' ? translate('common.billable').toLowerCase() : translate('common.nonBillable').toLowerCase(); | ||
| buildMessageFragmentForValue(translate, newBillable, oldBillable, translate('iou.expense'), true, setFragments, removalFragments, changeFragments); | ||
| } | ||
|
|
||
| const hasModifiedReimbursable = isReportActionOriginalMessageAnObject && 'oldReimbursable' in reportActionOriginalMessage && 'reimbursable' in reportActionOriginalMessage; | ||
| if (hasModifiedReimbursable) { | ||
| buildMessageFragmentForValue( | ||
| translate, | ||
| reportActionOriginalMessage?.reimbursable ?? '', | ||
| reportActionOriginalMessage?.oldReimbursable ?? '', | ||
| translate('iou.expense'), | ||
| true, | ||
| setFragments, | ||
| removalFragments, | ||
| changeFragments, | ||
| ); | ||
| const oldReimbursable = | ||
| reportActionOriginalMessage?.oldReimbursable === 'reimbursable' ? translate('iou.reimbursable').toLowerCase() : translate('iou.nonReimbursable').toLowerCase(); | ||
| const newReimbursable = reportActionOriginalMessage?.reimbursable === 'reimbursable' ? translate('iou.reimbursable').toLowerCase() : translate('iou.nonReimbursable').toLowerCase(); | ||
| buildMessageFragmentForValue(translate, newReimbursable, oldReimbursable, translate('iou.expense'), true, setFragments, removalFragments, changeFragments); | ||
| } | ||
|
|
||
| const hasModifiedAttendees = isReportActionOriginalMessageAnObject && 'oldAttendees' in reportActionOriginalMessage && 'newAttendees' in reportActionOriginalMessage; | ||
|
|
@@ -741,6 +732,13 @@ function getForReportActionTemp({ | |
| getMessageLine(translate, `\n${translate('iou.removed')}`, removalFragments); | ||
|
|
||
| if (message === '') { | ||
| // If we don't have enough structured information to build a detailed message but we | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these changes necessary for this PR? If not, can you please remove it so that it is more straight-forward to review?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, these changes are necessary. Beamanator flagged in his review that The same reasoning applies to the billable/reimbursable localization fix just above — both were required to maintain parity with the function being replaced. 🤖 This comment was generated with the assistance of an AI tool. |
||
| // know the change was AI-generated, fall back to an AI-attributed generic summary so | ||
| // users can still understand that Concierge updated the expense automatically. | ||
| if (reportActionOriginalMessage?.aiGenerated) { | ||
| return `${translate('iou.changedTheExpense')} ${translate('iou.basedOnAI')}`; | ||
| } | ||
|
|
||
| return translate('iou.changedTheExpense'); | ||
| } | ||
| return `${message.substring(1, message.length)}`; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.