Skip to content
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]: Optimistic message not set correctly with the BE message for approver who is not the admin #42389

Closed
wants to merge 2 commits into from
Closed
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
105 changes: 59 additions & 46 deletions src/libs/NextStepUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,52 +273,65 @@ function buildNextStep(

// Generates an optimistic nextStep once a report has been approved
case CONST.REPORT.STATUS_NUM.APPROVED:
// Self review
optimisticNextStep = {
type,
title: 'Next Steps:',
message: [
{
text: 'Waiting for ',
},
{
text: 'you',
type: 'strong',
},
{
text: ' to ',
},
{
text: 'pay',
type: 'strong',
},
{
text: ' %expenses.',
},
],
};

// Another owner
if (!isOwner) {
optimisticNextStep.message = [
{
text: 'Waiting for ',
},
{
text: managerDisplayName,
type: 'strong',
},
{
text: ' to ',
},
{
text: 'pay',
type: 'strong',
},
{
text: ' %expenses.',
},
];
// Approver is not the owner of the policy
if (submitToAccountID === currentUserAccountID && !isOwner) {
optimisticNextStep = {
type,
title: 'Finished!',
message: [
{
text: 'No further action required!',
},
],
};
} else {
// Self review
optimisticNextStep = {
type,
title: 'Next Steps:',
message: [
{
text: 'Waiting for ',
},
{
text: 'you',
type: 'strong',
},
{
text: ' to ',
},
{
text: 'pay',
type: 'strong',
},
{
text: ' %expenses.',
},
],
};

// Another owner
if (!isOwner) {
optimisticNextStep.message = [
{
text: 'Waiting for ',
},
{
text: managerDisplayName,
type: 'strong',
},
{
text: ' to ',
},
{
text: 'pay',
type: 'strong',
},
{
text: ' %expenses.',
},
];
}
}

break;
Expand Down
18 changes: 2 additions & 16 deletions tests/unit/NextStepUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,24 +512,10 @@ describe('libs/NextStepUtils', () => {

test('another owner', () => {
report.ownerAccountID = strangeAccountID;
optimisticNextStep.title = 'Next Steps:';
optimisticNextStep.title = 'Finished!';
optimisticNextStep.message = [
{
text: 'Waiting for ',
},
{
text: 'you',
type: 'strong',
},
{
text: ' to ',
},
{
text: 'pay',
type: 'strong',
},
{
text: ' %expenses.',
text: 'No further action required!',
},
];

Expand Down
Loading