Skip to content

Commit 3bcba2f

Browse files
committed
Fix Expense preview avatar shows fallback avatar when user has previous chat
1 parent c5df224 commit 3bcba2f

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/components/ReportActionAvatars/useReportPreviewSenderID.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {getAllNonDeletedTransactions} from '@libs/MoneyRequestReportUtils';
66
import {getPersonalDetailByEmail} from '@libs/PersonalDetailsUtils';
77
import {getOriginalMessage, isMoneyRequestAction} from '@libs/ReportActionsUtils';
88
import {isDM} from '@libs/ReportUtils';
9+
import {getCurrentUserAccountID} from '@userActions/Report';
910
import CONST from '@src/CONST';
1011
import ONYXKEYS from '@src/ONYXKEYS';
1112
import type {Report, ReportAction, Transaction} from '@src/types/onyx';
@@ -47,6 +48,10 @@ function useReportPreviewSenderID({iouReport, action, chatReport}: {action: Onyx
4748
canBeMissing: true,
4849
});
4950

51+
if (action?.isOptimisticAction && action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) {
52+
return getCurrentUserAccountID();
53+
}
54+
5055
// 1. If all amounts have the same sign - either all amounts are positive or all amounts are negative.
5156
// We have to do it this way because there can be a case when actions are not available
5257
// See: https://github.com/Expensify/App/pull/64802#issuecomment-3008944401

src/libs/ReportUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6709,6 +6709,7 @@ function buildOptimisticReportPreview(
67096709
actorAccountID: hasReceipt ? currentUserAccountID : reportActorAccountID,
67106710
childReportID: childReportID ?? iouReport?.reportID,
67116711
childMoneyRequestCount: 1,
6712+
isOptimisticAction: true,
67126713
childLastActorAccountID: currentUserAccountID,
67136714
childLastMoneyRequestComment: comment,
67146715
childRecentReceiptTransactionIDs: hasReceipt && !isEmptyObject(transaction) && transaction?.transactionID ? {[transaction.transactionID]: created} : undefined,

src/libs/actions/IOU.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,11 +1771,13 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR
17711771
[chat.createdAction.reportActionID]: {
17721772
pendingAction: null,
17731773
errors: null,
1774+
isOptimisticAction: null,
17741775
},
17751776
}
17761777
: {}),
17771778
[chat.reportPreviewAction.reportActionID]: {
17781779
pendingAction: null,
1780+
isOptimisticAction: null,
17791781
},
17801782
},
17811783
},
@@ -1788,12 +1790,14 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR
17881790
[iou.createdAction.reportActionID]: {
17891791
pendingAction: null,
17901792
errors: null,
1793+
isOptimisticAction: null,
17911794
},
17921795
}
17931796
: {}),
17941797
[iou.action.reportActionID]: {
17951798
pendingAction: null,
17961799
errors: null,
1800+
isOptimisticAction: null,
17971801
},
17981802
},
17991803
},
@@ -1807,6 +1811,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR
18071811
[transactionThreadCreatedReportAction.reportActionID]: {
18081812
pendingAction: null,
18091813
errors: null,
1814+
isOptimisticAction: null,
18101815
},
18111816
},
18121817
});

0 commit comments

Comments
 (0)