-
Notifications
You must be signed in to change notification settings - Fork 3.7k
refactor getPolicyExpenseReportOption #80209
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
7b1a5ff
b6a3974
72e62cb
015248c
e320f10
28eb206
1a941ba
93bf59c
242707c
3539376
82992fb
603b861
10ec503
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import {privateIsArchivedSelector} from '@selectors/ReportNameValuePairs'; | ||
| import React, {useCallback, useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
|
|
@@ -67,13 +68,23 @@ function SplitBillDetailsPage({route, report, reportAction}: SplitBillDetailsPag | |
| const reportAttributesDerived = useReportAttributes(); | ||
| const [betas] = useOnyx(ONYXKEYS.BETAS); | ||
| const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(report?.chatReportID)}`); | ||
| const [privateIsArchived] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, {selector: privateIsArchivedSelector}); | ||
|
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 it is better to reuse
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. I thought about it, but useReportIsArchived returns a boolean while getPolicyExpenseReportOption and the downstream chain accept a string
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. Hm, that's fair, but from what I can see, all the code referencing it uses I can open a separate GH for this.
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. Created here: #84608 |
||
|
|
||
| // In case this is workspace split expense, we manually add the workspace as the second participant of the split expense | ||
| // because we don't save any accountID in the report action's originalMessage other than the payee's accountID | ||
| let participants: Array<Participant | OptionData>; | ||
| if (isPolicyExpenseChat(report)) { | ||
| participants = [ | ||
| getParticipantsOption({accountID: participantAccountIDs.at(0), selected: true, reportID: ''}, personalDetails), | ||
| getPolicyExpenseReportOption({...report, selected: true, reportID}, currentUserPersonalDetails.accountID, personalDetails, report, chatReport, reportAttributesDerived), | ||
| getPolicyExpenseReportOption( | ||
| {...report, selected: true, reportID}, | ||
| privateIsArchived, | ||
| currentUserPersonalDetails.accountID, | ||
| personalDetails, | ||
| report, | ||
| chatReport, | ||
| reportAttributesDerived, | ||
| ), | ||
| ]; | ||
| } else { | ||
| participants = participantAccountIDs.map((accountID) => getParticipantsOption({accountID, selected: true, reportID: ''}, personalDetails)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import type {ReportNameValuePairs} from '@src/types/onyx'; | ||
|
|
||
| /** | ||
| * Selector that extracts only the private_isArchived value from a single ReportNameValuePairs entry | ||
| */ | ||
| const privateIsArchivedSelector = (reportNameValuePairs: OnyxEntry<ReportNameValuePairs>): string | undefined => reportNameValuePairs?.private_isArchived; | ||
|
|
||
| // eslint-disable-next-line import/prefer-default-export | ||
| export {privateIsArchivedSelector}; |
Uh oh!
There was an error while loading. Please reload this page.