Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1288,11 +1288,10 @@ function compareDuplicateTransactionFields(
return {keep, change};
}

function getTransactionID(threadReportID: string | undefined): string | undefined {
function getTransactionID(threadReportID?: string): string | undefined {
if (!threadReportID) {
return;
}

const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${threadReportID}`];
const parentReportAction = isThread(report) ? getReportAction(report.parentReportID, report.parentReportActionID) : undefined;
const IOUTransactionID = isMoneyRequestAction(parentReportAction) ? getOriginalMessage(parentReportAction)?.IOUTransactionID : undefined;
Expand Down
40 changes: 28 additions & 12 deletions src/libs/actions/PersonalDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (val) => {
currentUserEmail = val?.email ?? '';
currentUserAccountID = val?.accountID ?? -1;
currentUserAccountID = val?.accountID ?? CONST.DEFAULT_NUMBER_ID;
},
});

Expand Down Expand Up @@ -121,20 +121,36 @@ function updateDisplayName(firstName: string, lastName: string) {

function updateLegalName(legalFirstName: string, legalLastName: string) {
const parameters: UpdateLegalNameParams = {legalFirstName, legalLastName};

API.write(WRITE_COMMANDS.UPDATE_LEGAL_NAME, parameters, {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS,
value: {
legalFirstName,
legalLastName,
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS,
value: {
legalFirstName,
legalLastName,
},
},
];
// In case the user does not have a display name, we will update the display name based on the legal name
if (!allPersonalDetails?.[currentUserAccountID]?.firstName && !allPersonalDetails?.[currentUserAccountID]?.lastName) {
Comment thread
This conversation was marked as resolved.
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: {
[currentUserAccountID]: {
displayName: PersonalDetailsUtils.createDisplayName(currentUserEmail ?? '', {
firstName: legalFirstName,
lastName: legalLastName,
}),
},
firstName: legalFirstName,
lastName: legalLastName,
Comment on lines +146 to +147

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Themoonalsofall I think it supposed to go inside [currentUserAccountID], isn't it? write now it is getting storen into personal details list itself

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make a quick follow up PR to fix this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks @alitoshmatov. I'll create follow up PR soon.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alitoshmatov follow up PR #56399

},
],
});
}
API.write(WRITE_COMMANDS.UPDATE_LEGAL_NAME, parameters, {
optimisticData,
});

Navigation.goBack();
}

Expand Down