-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Payment due @abzokhattab] Make Concierge aware of the active report and/or selected transactions #86149
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
Merged
Merged
[Payment due @abzokhattab] Make Concierge aware of the active report and/or selected transactions #86149
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d1466c6
Store the currently opened report in Onyx
youssef-lr 42b4e33
Rename stuff. And unset the active reportID when unmounting.
youssef-lr b7dae0a
Remove unnecessary effect
youssef-lr 0251056
Add activeReportID to addComment call
youssef-lr 032aa07
Avoid overwriting activeReportID with Concierge's ID. Add comments.
youssef-lr 1fa59f3
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr 29ce804
Update naming
youssef-lr 7e4fd1e
Use currentReportID or currentRHPReportID from navigation to set side…
youssef-lr bcac18c
Cleanup
youssef-lr 619dd4d
JSON stringify sidePanelContext
youssef-lr 6df8e49
Cleanup
youssef-lr 53b3791
Fix Lint & TS
youssef-lr fe39d1d
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr 46fe425
Fix TS
youssef-lr 144a97c
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr c8140b0
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr 5bd7620
Include selected transactions or reports in context
youssef-lr aefa644
Send IDs as a string
youssef-lr 9cdd521
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr 892adc9
Extract logic into hook
youssef-lr 01e4cf1
Address comment
youssef-lr 9fba131
Tidy up code
youssef-lr 0187eb0
Send either selectedReportIDs or selectedTransactionIDs from the Repo…
youssef-lr 9c88b74
Bug fix
youssef-lr 1fc9ec7
Fix some edge cases
youssef-lr 3d2450a
Address comments
youssef-lr eaf5d99
Add test
youssef-lr 36087f0
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr 8889f68
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr f94b8d7
Fix TS
youssef-lr baa3349
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr 754b5d9
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr 4b3b2a4
Merge branch 'main' into youssef_concierge_anywhere_report_context
youssef-lr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/pages/inbox/report/ReportActionCompose/useSidePanelContext.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import {useMemo} from 'react'; | ||
| import {useSearchStateContext} from '@components/Search/SearchContext'; | ||
| import {useCurrentReportIDState} from '@hooks/useCurrentReportID'; | ||
| import useIsInSidePanel from '@hooks/useIsInSidePanel'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type * as OnyxTypes from '@src/types/onyx'; | ||
| import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
|
|
||
| function useSidePanelContext(reportID: string): OnyxTypes.SidePanelContext | undefined { | ||
| const isInSidePanel = useIsInSidePanel(); | ||
| const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); | ||
| const {currentReportID, currentRHPReportID} = useCurrentReportIDState(); | ||
| const {currentSearchQueryJSON, selectedTransactionIDs, selectedTransactions, selectedReports} = useSearchStateContext(); | ||
|
|
||
| return useMemo(() => { | ||
| if (conciergeReportID !== reportID || !isInSidePanel) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const contextReportID = currentRHPReportID ?? currentReportID ?? undefined; | ||
|
|
||
| // selectedTransactions (map) is populated from the Search list; selectedTransactionIDs (array) | ||
| // is populated from the report table view. The two are mutually exclusive. | ||
| const txIDsFromMap = !isEmptyObject(selectedTransactions) | ||
| ? Object.entries(selectedTransactions) | ||
| .filter(([, info]) => info.isSelected && !!info.transaction) | ||
| .map(([id]) => id) | ||
| : []; | ||
| const allTransactionIDs = txIDsFromMap.length > 0 ? txIDsFromMap : selectedTransactionIDs; | ||
| const selectedTransactionIDsForContext = allTransactionIDs.length > 0 ? allTransactionIDs.join(',') : undefined; | ||
|
|
||
| const selectedReportIDsForContext = | ||
| selectedReports.length > 0 | ||
| ? selectedReports | ||
| .map((r) => r.reportID) | ||
| .filter((id): id is string => !!id) | ||
| .join(',') || undefined | ||
| : undefined; | ||
|
|
||
| // This condition is reached when we are either in the global Reports => Reports page, or within a single expense report having multiple transactions. | ||
| // If we have selectedReportIDs, that means we're in the Reports page, otherwise we're in the expense report RHP. | ||
| if (currentSearchQueryJSON?.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { | ||
| return selectedReportIDsForContext ? {selectedReportIDs: selectedReportIDsForContext} : {reportID: contextReportID, selectedTransactionIDs: selectedTransactionIDsForContext}; | ||
| } | ||
|
|
||
| if (!contextReportID && !selectedTransactionIDsForContext && !selectedReportIDsForContext) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return {reportID: contextReportID, selectedTransactionIDs: selectedTransactionIDsForContext, selectedReportIDs: selectedReportIDsForContext}; | ||
| }, [conciergeReportID, reportID, isInSidePanel, currentSearchQueryJSON?.type, currentRHPReportID, currentReportID, selectedTransactionIDs, selectedTransactions, selectedReports]); | ||
| } | ||
|
|
||
| export default useSidePanelContext; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.