-
Notifications
You must be signed in to change notification settings - Fork 3.9k
decompose ReportActionsList: 1 #88392
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
rlinoz
merged 12 commits into
Expensify:main
from
callstack-internal:refactor/extract-report-actions-list-presentation
May 1, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dea53fb
extract ShowPreviousMessagesButton and ReportActionsListHeader from R…
adhorodyski be8fab2
Merge branch 'Expensify:main' into refactor/extract-report-actions-li…
adhorodyski c442a14
Merge remote-tracking branch 'exfy/main' into refactor/extract-report…
adhorodyski 181cb8f
fix lint errors in ReportActionsListHeaderTest
adhorodyski 7061801
narrow ShowPreviousMessagesButton prop to actionType
adhorodyski 3a774a1
Merge remote-tracking branch 'exfy/main' into refactor/extract-report…
adhorodyski 09c30f3
drop isConciergeSidePanel gate from ReportActionsListHeader
adhorodyski dcc1b85
centralize ShowPreviousMessagesButton gating in child
adhorodyski 2192b22
Merge branch 'Expensify:main' into refactor/extract-report-actions-li…
adhorodyski a4afa0d
Merge branch 'Expensify:main' into refactor/extract-report-actions-li…
adhorodyski ef911f6
Merge branch 'Expensify:main' into refactor/extract-report-actions-li…
adhorodyski e602bbd
fix lint
adhorodyski 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import React from 'react'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import ConciergeThinkingMessage from '@pages/home/report/ConciergeThinkingMessage'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ListBoundaryLoader from './ListBoundaryLoader'; | ||
|
|
||
| type ReportActionsListHeaderProps = { | ||
| /** The ID of the report being displayed */ | ||
| reportID: string; | ||
|
|
||
| /** Callback to retry loading newer chats after an error */ | ||
| onRetry: () => void; | ||
| }; | ||
|
|
||
| function ReportActionsListHeader({reportID, onRetry}: ReportActionsListHeaderProps) { | ||
| const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); | ||
|
|
||
| return ( | ||
| <> | ||
| <ConciergeThinkingMessage report={report} /> | ||
| <ListBoundaryLoader | ||
| type={CONST.LIST_COMPONENTS.HEADER} | ||
| onRetry={onRetry} | ||
| /> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default ReportActionsListHeader; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import Button from '@components/Button'; | ||
| import useIsInSidePanel from '@hooks/useIsInSidePanel'; | ||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {ReportAction} from '@src/types/onyx'; | ||
|
|
||
| type ShowPreviousMessagesButtonProps = { | ||
| /** The ID of the report this list item belongs to */ | ||
| reportID: string; | ||
|
|
||
| /** The action type of the report action being rendered for this list item */ | ||
| actionType: ReportAction['actionName']; | ||
|
|
||
| /** Whether there are previous messages hidden before the session start */ | ||
| hasPreviousMessages: boolean; | ||
|
|
||
| /** Whether the full message history is currently shown */ | ||
| showFullHistory: boolean; | ||
|
|
||
| /** Callback to reveal the full message history */ | ||
| onPress?: () => void; | ||
| }; | ||
|
|
||
| function ShowPreviousMessagesButton({reportID, actionType, hasPreviousMessages, showFullHistory, onPress}: ShowPreviousMessagesButtonProps) { | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const expensifyIcons = useMemoizedLazyExpensifyIcons(['UpArrow']); | ||
| const isInSidePanel = useIsInSidePanel(); | ||
| const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); | ||
| const isConciergeSidePanel = isInSidePanel && reportID === conciergeReportID; | ||
|
|
||
| if (!isConciergeSidePanel) { | ||
| return null; | ||
| } | ||
| if (!onPress) { | ||
| return null; | ||
| } | ||
| if (actionType !== CONST.REPORT.ACTIONS.TYPE.CREATED) { | ||
| return null; | ||
| } | ||
| if (!hasPreviousMessages) { | ||
| return null; | ||
| } | ||
| if (showFullHistory) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <View style={[styles.flexRow, styles.alignItemsCenter, styles.pv3, styles.mh5]}> | ||
| <View style={[styles.threadDividerLine, styles.ml0, styles.mr0, styles.flexGrow1]} /> | ||
| <View> | ||
| <Button | ||
| small | ||
| shouldShowRightIcon | ||
| iconRight={expensifyIcons.UpArrow} | ||
| text={translate('common.concierge.showHistory')} | ||
| onPress={onPress} | ||
| /> | ||
| </View> | ||
| <View style={[styles.threadDividerLine, styles.ml0, styles.mr0, styles.flexGrow1]} /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default ShowPreviousMessagesButton; | ||
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,65 @@ | ||
| import {render, screen} from '@testing-library/react-native'; | ||
| import React from 'react'; | ||
| import ReportActionsListHeader from '@pages/inbox/report/ReportActionsListHeader'; | ||
|
|
||
| const REPORT_ID = '42'; | ||
|
|
||
| const mockUseOnyx = jest.fn<unknown[], [string]>(); | ||
|
|
||
| jest.mock('@hooks/useOnyx', () => ({ | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| __esModule: true, | ||
| default: (key: string) => mockUseOnyx(key), | ||
| })); | ||
|
|
||
| jest.mock('@pages/home/report/ConciergeThinkingMessage', () => { | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
| const {View: MockView} = require('react-native'); | ||
| return { | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| __esModule: true, | ||
| default: () => <MockView testID="ConciergeThinkingMessage" />, | ||
| }; | ||
| }); | ||
|
|
||
| jest.mock('@pages/inbox/report/ListBoundaryLoader', () => { | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
| const {View: MockView} = require('react-native'); | ||
| return { | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| __esModule: true, | ||
| default: () => <MockView testID="ListBoundaryLoader" />, | ||
| }; | ||
| }); | ||
|
|
||
| describe('ReportActionsListHeader', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| mockUseOnyx.mockImplementation((key: string) => { | ||
| if (key.startsWith('report_')) { | ||
| return [{reportID: REPORT_ID}]; | ||
| } | ||
| return [undefined]; | ||
| }); | ||
| }); | ||
|
|
||
| it('renders ListBoundaryLoader', () => { | ||
| render( | ||
| <ReportActionsListHeader | ||
| reportID={REPORT_ID} | ||
| onRetry={jest.fn()} | ||
| />, | ||
| ); | ||
| expect(screen.getByTestId('ListBoundaryLoader')).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('renders ConciergeThinkingMessage and delegates visibility gating to that component', () => { | ||
| render( | ||
| <ReportActionsListHeader | ||
| reportID={REPORT_ID} | ||
| onRetry={jest.fn()} | ||
| />, | ||
| ); | ||
| expect(screen.getByTestId('ConciergeThinkingMessage')).toBeTruthy(); | ||
| }); | ||
| }); |
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.