Skip to content
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

Fix a report preview in the comments of one expense report. #44366

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
725c3dd
getCombinedReportActions keep filtering logic when transactionThreadR…
wildan-m Jun 22, 2024
2e2730a
Revert "getCombinedReportActions keep filtering logic when transactio…
wildan-m Jun 22, 2024
4c6d350
getCombinedReportActions keep filtering logic when transactionThreadR…
wildan-m Jun 22, 2024
fc655a5
Merge branch 'main' of https://github.com/wildan-m/App into wildan/fi…
wildan-m Jun 23, 2024
f09121f
fix issue with multiple IOU
wildan-m Jun 23, 2024
bf11ad4
Merge branch 'main' of https://github.com/wildan-m/App into wildan/fi…
wildan-m Jun 25, 2024
6ce37c7
Use IOU count to show sub-report preview
wildan-m Jun 25, 2024
d47b5fd
Merge branch 'main' of https://github.com/wildan-m/App into wildan/fi…
wildan-m Jun 25, 2024
b08e4aa
Revert unnecessary change
wildan-m Jun 25, 2024
e07a41f
Merge branch 'main' of https://github.com/wildan-m/App into wildan/fi…
wildan-m Jun 25, 2024
fac07ed
Use transactionThreadReportID instead of recounting IOU
wildan-m Jun 25, 2024
8fc1831
missing dependency
wildan-m Jun 25, 2024
778b3e3
Update src/pages/home/report/ReportActionsView.tsx
wildan-m Jun 26, 2024
b316c2a
Update src/libs/ReportActionsUtils.ts
wildan-m Jun 26, 2024
8381d0b
Add transactionThreadReportID to getCombinedReportActions
wildan-m Jun 26, 2024
9a247c3
change transactionThreadReportID to mandatory
wildan-m Jun 26, 2024
23507b9
remove reportID in ReportActionViews' getCombinedReportActions
wildan-m Jun 26, 2024
8a89228
remove unnecessary dependency
wildan-m Jun 26, 2024
6778162
remove unnecessarcy check
wildan-m Jun 26, 2024
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
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Onyx.connect({
const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]]);
if (transactionThreadReportID) {
const transactionThreadReportActionsArray = Object.values(actions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {});
sortedReportActions = ReportActionUtils.getCombinedReportActions(reportActionsArray, transactionThreadReportActionsArray, reportID);
sortedReportActions = ReportActionUtils.getCombinedReportActions(reportActionsArray, transactionThreadReportID, transactionThreadReportActionsArray, reportID);
}

lastReportActions[reportID] = sortedReportActions[0];
Expand Down
10 changes: 7 additions & 3 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,18 @@ function shouldIgnoreGap(currentReportAction: ReportAction | undefined, nextRepo
* Returns a sorted and filtered list of report actions from a report and it's associated child
* transaction thread report in order to correctly display reportActions from both reports in the one-transaction report view.
*/
function getCombinedReportActions(reportActions: ReportAction[], transactionThreadReportActions: ReportAction[], reportID?: string): ReportAction[] {
if (isEmptyObject(transactionThreadReportActions)) {
function getCombinedReportActions(
reportActions: ReportAction[],
transactionThreadReportID: string | null,
transactionThreadReportActions: ReportAction[],
reportID?: string,
): ReportAction[] {
if (_.isEmpty(transactionThreadReportID)) {
return reportActions;
}

// Filter out the created action from the transaction thread report actions, since we already have the parent report's created action in `reportActions`
const filteredTransactionThreadReportActions = transactionThreadReportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED);

const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const isSelfDM = report?.chatType === CONST.REPORT.CHAT_TYPE.SELF_DM;
// Filter out request and send money request actions because we don't want to show any preview actions for one transaction reports
Expand Down
5 changes: 3 additions & 2 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function ReportActionsView({
isLoadingNewerReportActions = false,
hasLoadingNewerReportActionsError = false,
isReadyForCommentLinking = false,
transactionThreadReportID,
}: ReportActionsViewProps) {
useCopySelectionHelper();
const reactionListRef = useContext(ReactionListContext);
Expand Down Expand Up @@ -157,8 +158,8 @@ function ReportActionsView({
// Get a sorted array of reportActions for both the current report and the transaction thread report associated with this report (if there is one)
// so that we display transaction-level and report-level report actions in order in the one-transaction view
const combinedReportActions = useMemo(
() => ReportActionsUtils.getCombinedReportActions(allReportActions, transactionThreadReportActions),
[allReportActions, transactionThreadReportActions],
() => ReportActionsUtils.getCombinedReportActions(allReportActions, transactionThreadReportID ?? null, transactionThreadReportActions),
[allReportActions, transactionThreadReportActions, transactionThreadReportID],
);

const parentReportActionForTransactionThread = useMemo(
Expand Down
Loading