-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: Expensify card link navigates to wallet #50039
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
f1ef836
dafc2b7
a668f6a
c9457fc
abbd04e
9e8dfb1
484486b
793afd8
abb9687
7f19976
015e07d
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,7 +10,7 @@ import type {TranslationPaths} from '@src/languages/types'; | |||||||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||||||||
| import ROUTES from '@src/ROUTES'; | ||||||||
| import type {OnyxInputOrEntry, PrivatePersonalDetails} from '@src/types/onyx'; | ||||||||
| import type {IssueNewCardOriginalMessage, JoinWorkspaceResolution, OriginalMessageChangeLog, OriginalMessageExportIntegration} from '@src/types/onyx/OriginalMessage'; | ||||||||
| import type {JoinWorkspaceResolution, OriginalMessageChangeLog, OriginalMessageExportIntegration} from '@src/types/onyx/OriginalMessage'; | ||||||||
| import type Report from '@src/types/onyx/Report'; | ||||||||
| import type ReportAction from '@src/types/onyx/ReportAction'; | ||||||||
| import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction'; | ||||||||
|
|
@@ -25,6 +25,7 @@ import Log from './Log'; | |||||||
| import type {MessageElementBase, MessageTextElement} from './MessageElement'; | ||||||||
| import Parser from './Parser'; | ||||||||
| import * as PersonalDetailsUtils from './PersonalDetailsUtils'; | ||||||||
| import * as PolicyUtils from './PolicyUtils'; | ||||||||
| import * as ReportConnection from './ReportConnection'; | ||||||||
| import type {OptimisticIOUReportAction, PartialReportAction} from './ReportUtils'; | ||||||||
| import StringUtils from './StringUtils'; | ||||||||
|
|
@@ -1728,13 +1729,24 @@ function isCardIssuedAction(reportAction: OnyxEntry<ReportAction>) { | |||||||
| return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL, CONST.REPORT.ACTIONS.TYPE.CARD_MISSING_ADDRESS); | ||||||||
| } | ||||||||
|
|
||||||||
| function getCardIssuedMessage(reportAction: OnyxEntry<ReportAction>, shouldRenderHTML = false) { | ||||||||
| const assigneeAccountID = (getOriginalMessage(reportAction) as IssueNewCardOriginalMessage)?.assigneeAccountID; | ||||||||
| function getCardIssuedMessage(reportAction: OnyxEntry<ReportAction>, shouldRenderHTML = false, policyID = '-1') { | ||||||||
| const cardIssuedActionOriginalMessage = isActionOfType( | ||||||||
| reportAction, | ||||||||
| CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED, | ||||||||
| CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL, | ||||||||
| CONST.REPORT.ACTIONS.TYPE.CARD_MISSING_ADDRESS, | ||||||||
| ) | ||||||||
| ? getOriginalMessage(reportAction) | ||||||||
| : undefined; | ||||||||
|
|
||||||||
| const assigneeAccountID = cardIssuedActionOriginalMessage?.assigneeAccountID ?? -1; | ||||||||
| const cardID = cardIssuedActionOriginalMessage?.cardID ?? -1; | ||||||||
| const assigneeDetails = PersonalDetailsUtils.getPersonalDetailsByIDs([assigneeAccountID], currentUserAccountID ?? -1).at(0); | ||||||||
|
|
||||||||
| const isPolicyAdmin = PolicyUtils.isPolicyAdmin(PolicyUtils.getPolicy(policyID)); | ||||||||
|
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. I think this is wrong if policyID is -1, no?
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. Yep,
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. This sounds wrong, because Line 579 in 9e1f21a
But also checking with the team about the -1 recommendation you linked above
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.
Line 579 in 9e1f21a
is false so undefined will be returned because of: Line 582 in 9e1f21a
I think
|
||||||||
| const assignee = shouldRenderHTML ? `<mention-user accountID="${assigneeAccountID}"/>` : assigneeDetails?.firstName ?? assigneeDetails?.login ?? ''; | ||||||||
| const navigateRoute = isPolicyAdmin ? ROUTES.EXPENSIFY_CARD_DETAILS.getRoute(policyID, String(cardID)) : ROUTES.SETTINGS_DOMAINCARD_DETAIL.getRoute(String(cardID)); | ||||||||
| const link = shouldRenderHTML | ||||||||
| ? `<a href='${environmentURL}/${ROUTES.SETTINGS_WALLET}'>${Localize.translateLocal('cardPage.expensifyCard')}</a>` | ||||||||
| ? `<a href='${environmentURL}/${navigateRoute}'>${Localize.translateLocal('cardPage.expensifyCard')}</a>` | ||||||||
| : Localize.translateLocal('cardPage.expensifyCard'); | ||||||||
|
|
||||||||
| const missingDetails = | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why -1 and not 0 or null? (same in all the ones below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the
policyIDprop of thereportispolicyID?: string, so I need to add the fallback value as '-1' to fix the type error based on the docs: https://github.com/Expensify/App/blob/main/contributingGuides/STYLE.md#default-value-for-inexistent-idsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posted about this here https://expensify.slack.com/archives/C01GTK53T8Q/p1728329641957179 and we will be undoing this, but I'll go ahead and merge this