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 - “Submitted $amount” system message appears for a moment when Employee submit IOU #39321

Merged
merged 17 commits into from
Apr 22, 2024
Merged
Changes from 7 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
45 changes: 41 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3275,6 +3275,41 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa
return expenseReport;
}

function getIOUSubmittedMessage(report: OnyxEntry<Report>) {
const policy = getPolicy(report?.policyID);
const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.submitsTo ?? 0);
let submittedToDisplayName: string;
if (ownerPersonalDetails?.accountID === currentUserAccountID) {
submittedToDisplayName = 'yourself';
} else {
submittedToDisplayName = ownerPersonalDetails?.displayName
? `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}`
FitseTLT marked this conversation as resolved.
Show resolved Hide resolved
: '';
}
return [
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
style: 'strong',
text: 'You',
},
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
style: 'normal',
text: ' submitted this report',
},
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
style: 'normal',
text: ' to ',
},
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
style: 'strong',
text: submittedToDisplayName,
},
];
}

/**
* @param iouReportID - the report ID of the IOU report the action belongs to
* @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split)
Expand All @@ -3284,8 +3319,13 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa
* @param paymentType - IOU paymentMethodType. Can be oneOf(Elsewhere, Expensify)
* @param isSettlingUp - Whether we are settling up an IOU
*/
function getIOUReportActionMessage(iouReportID: string, type: string, total: number, comment: string, currency: string, paymentType = '', isSettlingUp = false): [Message] {
function getIOUReportActionMessage(iouReportID: string, type: string, total: number, comment: string, currency: string, paymentType = '', isSettlingUp = false): Message[] {
const report = getReport(iouReportID);

pecanoro marked this conversation as resolved.
Show resolved Hide resolved
if (type === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) {
return getIOUSubmittedMessage(!isEmptyObject(report) ? report : null);
}

const amount =
type === CONST.IOU.REPORT_ACTION_TYPE.PAY
? CurrencyUtils.convertToDisplayString(getMoneyRequestSpendBreakdown(!isEmptyObject(report) ? report : null).totalDisplaySpend, currency)
Expand All @@ -3307,9 +3347,6 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num
case CONST.REPORT.ACTIONS.TYPE.APPROVED:
iouMessage = `approved ${amount}`;
break;
case CONST.REPORT.ACTIONS.TYPE.SUBMITTED:
FitseTLT marked this conversation as resolved.
Show resolved Hide resolved
iouMessage = `submitted ${amount}`;
break;
case CONST.IOU.REPORT_ACTION_TYPE.CREATE:
iouMessage = `requested ${amount}${comment && ` for ${comment}`}`;
break;
Expand Down
Loading