Skip to content

Commit

Permalink
Fix cannot clear error of modified action in one transaction report
Browse files Browse the repository at this point in the history
  • Loading branch information
nkdengineer committed Apr 3, 2024
1 parent 6463de6 commit 4aeafee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ function isMoneyRequestReport(reportOrID: OnyxEntry<Report> | EmptyObject | stri
* Checks if a report has only one transaction associated with it
*/
function isOneTransactionReport(reportID: string): boolean {
const reportActions = reportActionsByReport?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? ([] as ReportAction[]);
const reportActions = reportActionsByReport?.[reportID] ?? ([] as ReportAction[]);
return ReportActionsUtils.getOneTransactionThreadReportID(reportActions) !== null;
}

Expand Down Expand Up @@ -4984,7 +4984,12 @@ function canUserPerformWriteAction(report: OnyxEntry<Report>) {
* Returns ID of the original report from which the given reportAction is first created.
*/
function getOriginalReportID(reportID: string, reportAction: OnyxEntry<ReportAction>): string | undefined {
const currentReportAction = ReportActionsUtils.getReportAction(reportID, reportAction?.reportActionID ?? '');
const reportActions = reportActionsByReport?.[reportID];
const currentReportAction = reportActions?.[reportAction?.reportActionID ?? ''] ?? null;
const transactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(reportActions ?? ([] as ReportAction[]));
if (transactionThreadReportID !== null) {
return Object.keys(currentReportAction ?? {}).length === 0 ? transactionThreadReportID : reportID;
}
return isThreadFirstChat(reportAction, reportID) && Object.keys(currentReportAction ?? {}).length === 0
? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.parentReportID
: reportID;
Expand Down

0 comments on commit 4aeafee

Please sign in to comment.