Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,6 @@
allReports={allReports}
policies={policies}
reportAction={reportAction}
reportActions={reportActions}
parentReportAction={parentReportAction}
parentReportActionForTransactionThread={EmptyParentReportActionForTransactionThread}
index={index}
Expand Down Expand Up @@ -605,7 +604,6 @@
},
[
visibleReportActions,
reportActions,
reportActionsObject,
parentReportAction,
report,
Expand Down Expand Up @@ -641,7 +639,7 @@
reportScrollManager.scrollToEnd();
readActionSkipped.current = false;
readNewestAction(report.reportID);
}, [setIsFloatingMessageCounterVisible, hasNewestReportAction, reportScrollManager, report.reportID]);

Check warning on line 642 in src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useCallback has a missing dependency: 'introSelected'. Either include it or remove the dependency array

Check warning on line 642 in src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has a missing dependency: 'introSelected'. Either include it or remove the dependency array

const scrollToNewTransaction = useCallback(
(pageY: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ function ChatListItem<TItem extends ListItem>({
allReports={allReports}
action={reportActionItem}
report={report}
reportActions={[]}
onPress={() => onSelectRow(item)}
parentReportAction={undefined}
displayAsGroup={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ function DebugReportActionCreatePage({
policies={policies}
action={JSON.parse(draftReportAction.replaceAll('\n', '')) as ReportAction}
report={{reportID}}
reportActions={[]}
parentReportAction={undefined}
displayAsGroup={false}
isMostRecentIOUReportAction={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function DebugReportActionPreview({reportAction, reportID}: DebugReportActionPre
policies={policies}
action={reportAction ?? ({} as ReportAction)}
report={report ?? ({} as Report)}
reportActions={[]}
parentReportAction={undefined}
displayAsGroup={false}
isMostRecentIOUReportAction={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ function DuplicateTransactionItem({transaction, index, allReports, policies, onP
report={report}
parentReportAction={getReportAction(report?.parentReportID, report?.parentReportActionID)}
index={index}
reportActions={Object.values(reportActions ?? {})}
displayAsGroup={false}
shouldDisplayNewMarker={false}
isMostRecentIOUReportAction={false}
Expand Down
6 changes: 1 addition & 5 deletions src/pages/inbox/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ type PureReportActionItemProps = {
/** The transaction thread report associated with the report for this action, if any */
transactionThreadReport?: OnyxEntry<OnyxTypes.Report>;

/** Array of report actions for the report for this action */
// eslint-disable-next-line react/no-unused-prop-types
reportActions: OnyxTypes.ReportAction[];

/** Report action belonging to the report's parent */
parentReportAction: OnyxEntry<OnyxTypes.ReportAction>;

Expand Down Expand Up @@ -2194,14 +2190,14 @@ export default memo(PureReportActionItem, (prevProps, nextProps) => {
prevProps.report?.description === nextProps.report?.description &&
isCompletedTaskReport(prevProps.report) === isCompletedTaskReport(nextProps.report) &&
prevProps.report?.managerID === nextProps.report?.managerID &&
prevProps.index === nextProps.index &&
prevProps.shouldHideThreadDividerLine === nextProps.shouldHideThreadDividerLine &&
prevProps.report?.total === nextProps.report?.total &&
prevProps.report?.nonReimbursableTotal === nextProps.report?.nonReimbursableTotal &&
prevProps.report?.policyAvatar === nextProps.report?.policyAvatar &&
prevProps.linkedReportActionID === nextProps.linkedReportActionID &&
deepEqual(prevProps.report?.fieldList, nextProps.report?.fieldList) &&
deepEqual(prevProps.transactionThreadReport, nextProps.transactionThreadReport) &&
deepEqual(prevProps.reportActions, nextProps.reportActions) &&
deepEqual(prevParentReportAction, nextParentReportAction) &&
Comment on lines 2198 to 2201

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Compare index in memoized report action item

The memo comparator no longer has any fallback that changes when list ordering changes, but it still does not compare index, so an action can skip re-render when new actions are inserted ahead of it. In that case ReportActionItemMessageEdit keeps using a stale index for scrollToIndex(...) (see src/pages/inbox/report/ReportActionItemMessageEdit.tsx), which can scroll/focus the wrong row while editing if another message arrives. Please include index (or another ordering signal) in the comparator to keep edit-mode behavior in sync with reordered items.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, added index to comparison

prevProps.draftMessage === nextProps.draftMessage &&
prevProps.iouReport?.reportID === nextProps.iouReport?.reportID &&
Expand Down
5 changes: 0 additions & 5 deletions src/pages/inbox/report/ReportActionItemParentAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ type ReportActionItemParentActionProps = {
/** The transaction thread report associated with the current report, if any */
transactionThreadReport: OnyxEntry<OnyxTypes.Report>;

/** Array of report actions for this report */
reportActions: OnyxTypes.ReportAction[];

/** Report actions belonging to the report's parent */
parentReportAction: OnyxEntry<OnyxTypes.ReportAction>;

Expand Down Expand Up @@ -98,7 +95,6 @@ function ReportActionItemParentAction({
policies,
report,
transactionThreadReport,
reportActions,
parentReportAction,
index = 0,
shouldHideThreadDividerLine = false,
Expand Down Expand Up @@ -214,7 +210,6 @@ function ReportActionItemParentAction({
}
parentReportAction={parentReportAction}
report={ancestorReport}
reportActions={reportActions}
transactionThreadReport={transactionThreadReport}
action={ancestorReportAction}
displayAsGroup={false}
Expand Down
2 changes: 0 additions & 2 deletions src/pages/inbox/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ function ReportActionsList({
allReports={allReports}
policies={policies}
reportAction={reportAction}
reportActions={sortedReportActions}
parentReportAction={parentReportAction}
parentReportActionForTransactionThread={parentReportActionForTransactionThread}
index={index}
Expand Down Expand Up @@ -735,7 +734,6 @@ function ReportActionsList({
emojiReactions,
allReports,
policies,
sortedReportActions,
parentReportAction,
parentReportActionForTransactionThread,
report,
Expand Down
6 changes: 0 additions & 6 deletions src/pages/inbox/report/ReportActionsListItemRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ type ReportActionsListItemRendererProps = {
/** All the data of the action item */
reportAction: ReportAction;

/** Array of report actions for the report */
reportActions: ReportAction[];

/** All the data of the transaction collection */
transactions?: Array<OnyxEntry<Transaction>>;

Expand Down Expand Up @@ -109,7 +106,6 @@ function ReportActionsListItemRenderer({
allReports,
policies,
reportAction,
reportActions = [],
transactions,
parentReportAction,
index,
Expand Down Expand Up @@ -222,7 +218,6 @@ function ReportActionsListItemRenderer({
parentReportAction={parentReportAction}
reportID={report.reportID}
report={report}
reportActions={reportActions}
transactionThreadReport={transactionThreadReport}
index={index}
isFirstVisibleReportAction={isFirstVisibleReportAction}
Expand Down Expand Up @@ -250,7 +245,6 @@ function ReportActionsListItemRenderer({
transactionThreadReport={transactionThreadReport}
parentReportActionForTransactionThread={parentReportActionForTransactionThread}
action={action}
reportActions={reportActions}
linkedReportActionID={linkedReportActionID}
displayAsGroup={displayAsGroup}
transactions={transactions}
Expand Down
6 changes: 0 additions & 6 deletions tests/ui/PureReportActionItemTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ describe('PureReportActionItem', () => {
policies={undefined}
personalPolicyID={undefined}
report={undefined}
reportActions={[]}
parentReportAction={undefined}
action={action}
displayAsGroup={false}
Expand Down Expand Up @@ -280,7 +279,6 @@ describe('PureReportActionItem', () => {
policies={{testPolicy: dewPolicy as Policy}}
policy={dewPolicy as Policy}
report={{reportID: 'testReport', policyID: 'testPolicy'}}
reportActions={[]}
parentReportAction={undefined}
action={action}
displayAsGroup={false}
Expand Down Expand Up @@ -340,7 +338,6 @@ describe('PureReportActionItem', () => {
policies={{testPolicy: basicPolicy as Policy}}
policy={basicPolicy as Policy}
report={{reportID: 'testReport', policyID: 'testPolicy'}}
reportActions={[]}
parentReportAction={undefined}
action={action}
displayAsGroup={false}
Expand Down Expand Up @@ -411,7 +408,6 @@ describe('PureReportActionItem', () => {
policies={undefined}
personalPolicyID={undefined}
report={report}
reportActions={[]}
parentReportAction={undefined}
action={action}
displayAsGroup={false}
Expand Down Expand Up @@ -477,7 +473,6 @@ describe('PureReportActionItem', () => {
policies={undefined}
personalPolicyID={undefined}
report={report}
reportActions={[]}
parentReportAction={undefined}
action={action}
displayAsGroup={false}
Expand Down Expand Up @@ -529,7 +524,6 @@ describe('PureReportActionItem', () => {
policies={undefined}
personalPolicyID={undefined}
report={report}
reportActions={[]}
parentReportAction={undefined}
action={action}
displayAsGroup={false}
Expand Down
Loading