Skip to content

Commit

Permalink
Merge pull request #9956 from Expensify/marcaaron-fixBuildOptimisticR…
Browse files Browse the repository at this point in the history
…eportActionCrash

Get current user personal details directly in `Report.js`

(cherry picked from commit ed3be19)
  • Loading branch information
marcaaron authored and OSBotify committed Jul 22, 2022
1 parent 83abbaf commit 146e0de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ Onyx.connect({
callback: val => lastViewedReportID = val ? Number(val) : null,
});

let myPersonalDetails;
let personalDetails;
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS,
callback: val => myPersonalDetails = val[currentUserEmail],
callback: val => personalDetails = val,
});

const allReports = {};
Expand Down Expand Up @@ -859,7 +859,7 @@ function buildOptimisticReportAction(reportID, text, file) {
person: [
{
style: 'strong',
text: myPersonalDetails.displayName || currentUserEmail,
text: lodashGet(personalDetails, [currentUserEmail, 'displayName'], currentUserEmail),
type: 'TEXT',
},
],
Expand All @@ -868,7 +868,7 @@ function buildOptimisticReportAction(reportID, text, file) {
// Use the client generated ID as a optimistic action ID so we can remove it later
sequenceNumber: optimisticReportActionID,
clientID: optimisticReportActionID,
avatar: myPersonalDetails.avatar,
avatar: lodashGet(personalDetails, [currentUserEmail, 'avatar'], ReportUtils.getDefaultAvatar(currentUserEmail)),
timestamp: moment().unix(),
message: [
{
Expand Down

0 comments on commit 146e0de

Please sign in to comment.