-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 Reddot pinned chat appears for approver after failed scanned #39970
Changes from 9 commits
69263a4
fe5f752
1303c69
f082a5a
ec854c5
48ad489
590547f
1be1d08
de0ae91
4d03c16
4560da2
3fbf0f7
8866eb7
83500fc
97ce514
4c35a47
0c68919
6e342bc
4ef770d
728ae68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2586,14 +2586,6 @@ function areAllRequestsBeingSmartScanned(iouReportID: string, reportPreviewActio | |
return transactionsWithReceipts.every((transaction) => TransactionUtils.isReceiptBeingScanned(transaction)); | ||
} | ||
|
||
/** | ||
* Check if any of the transactions in the report has required missing fields | ||
* | ||
*/ | ||
function hasMissingSmartscanFields(iouReportID: string): boolean { | ||
return TransactionUtils.getAllReportTransactions(iouReportID).some((transaction) => TransactionUtils.hasMissingSmartscanFields(transaction)); | ||
} | ||
|
||
/** | ||
* Get the transactions related to a report preview with receipts | ||
* Get the details linked to the IOU reportAction | ||
|
@@ -2610,6 +2602,29 @@ function getLinkedTransaction(reportAction: OnyxEntry<ReportAction | OptimisticI | |
return allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? {}; | ||
} | ||
|
||
/** | ||
* Check if any of the transactions in the report has required missing fields | ||
* | ||
dukenv0307 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* NOTE: The function hasMissingSmartscanFields is used on both LHN preview and report action, | ||
dukenv0307 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* so we need to create a isLHNPreview to handle both cases above | ||
dukenv0307 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
function hasMissingSmartscanFields(iouReportID: string, isLHNPreview?: boolean): boolean { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't where we landed
Let's change this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created shouldShowRBRForMissingSmartscanFields method |
||
if (isLHNPreview) { | ||
dukenv0307 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const reportActions = Object.values(ReportActionsUtils.getAllReportActions(iouReportID)); | ||
return reportActions.some((action) => { | ||
if (!ReportActionsUtils.isMoneyRequestAction(action)) { | ||
return false; | ||
} | ||
const transaction = getLinkedTransaction(action); | ||
if (isEmptyObject(transaction)) { | ||
return false; | ||
} | ||
return TransactionUtils.hasMissingSmartscanFields(transaction) && currentUserAccountID === action?.actorAccountID; | ||
}); | ||
} | ||
return TransactionUtils.getAllReportTransactions(iouReportID).some((transaction) => TransactionUtils.hasMissingSmartscanFields(transaction)); | ||
dukenv0307 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/** | ||
* Given a parent IOU report action get report name for the LHN. | ||
*/ | ||
|
@@ -5736,13 +5751,13 @@ function canEditPolicyDescription(policy: OnyxEntry<Policy>): boolean { | |
/** | ||
* Checks if report action has error when smart scanning | ||
*/ | ||
function hasSmartscanError(reportActions: ReportAction[]) { | ||
function hasSmartscanError(reportActions: ReportAction[], isLHNPreview: boolean) { | ||
return reportActions.some((action) => { | ||
if (!ReportActionsUtils.isSplitBillAction(action) && !ReportActionsUtils.isReportPreviewAction(action)) { | ||
return false; | ||
} | ||
const IOUReportID = ReportActionsUtils.getIOUReportIDFromReportActionPreview(action); | ||
const isReportPreviewError = ReportActionsUtils.isReportPreviewAction(action) && hasMissingSmartscanFields(IOUReportID) && !isSettled(IOUReportID); | ||
const isReportPreviewError = ReportActionsUtils.isReportPreviewAction(action) && hasMissingSmartscanFields(IOUReportID, isLHNPreview) && !isSettled(IOUReportID); | ||
const transactionID = (action.originalMessage as IOUMessage).IOUTransactionID ?? '0'; | ||
const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? {}; | ||
const isSplitBillError = ReportActionsUtils.isSplitBillAction(action) && TransactionUtils.hasMissingSmartscanFields(transaction as Transaction); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we calling
ReportUtils.hasSmartscanError
from anywhere else? Do we need the second param?Even if we need it, I don't think it should be a separate param, and instead we should have that check outside of the
ReportUtils.hasSmartscanError
function, since that function name sounds like it shouldn't care aboutisLHNPreview
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No
I think we still need to create a
isLHNPreview
param then handle both case (isLHNPreview
istrue
orfalse
) inhasSmartscanError
to reduce the duplicate logics.As you can see, if we do like this, we just need to create a new variable,
hasMissingField
and apply a minor change toisReportPreviewError
, the rest logic does not change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm not following or I'm missing something, because if we always pass this as true, this doesn't make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. I removed
isLHNPreview
in commit