Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8300b62
Show report total and report status in the new report preview component
jakubkalinski0 Jul 16, 2025
461eb5c
Small fixes to the comments
jakubkalinski0 Jul 16, 2025
f869b7f
Small code cleanup in the MoneyRequestReportPreviewContent.tsx component
jakubkalinski0 Jul 16, 2025
fc314ca
Updating code style after running prettier
jakubkalinski0 Jul 16, 2025
ebc4817
Code adjusted to PR comments
jakubkalinski0 Jul 17, 2025
0aaa2b9
Commit after prettier changes
jakubkalinski0 Jul 17, 2025
6b4af2a
Fixing typecheck in languages
jakubkalinski0 Jul 17, 2025
399c574
Small style cleanup
jakubkalinski0 Jul 17, 2025
2edf3e6
Update src/libs/ReportUtils.ts
jakubkalinski0 Jul 18, 2025
8e8c3d3
Resolving comments pointed out by @Kicu in review
jakubkalinski0 Jul 18, 2025
45109a1
Merge branch 'jakubkalinski0/Show-report-total-and-report-status-in-t…
jakubkalinski0 Jul 18, 2025
12fd5aa
Removing testID from subheader
jakubkalinski0 Jul 18, 2025
19649f6
Removed min-height from the report title
jakubkalinski0 Jul 18, 2025
38cfcd4
Changes after running prettier
jakubkalinski0 Jul 18, 2025
dfd6f8d
Added skeleton for the subheader
jakubkalinski0 Jul 18, 2025
fc5ffa2
Changed the localization of approve/paid icon to the subheader
jakubkalinski0 Jul 18, 2025
96674d5
Added the visible 'View' button during loading
jakubkalinski0 Jul 18, 2025
e7a8682
Small code styling changes
jakubkalinski0 Jul 18, 2025
509f3c2
Commit after running prettier
jakubkalinski0 Jul 18, 2025
9e70810
Small adjustments to the icons
jakubkalinski0 Jul 18, 2025
e14c1f7
Fixed gap when the icon is missing
jakubkalinski0 Jul 21, 2025
92e710b
Centered icons and placed title, subheader and arrow buttons in one b…
jakubkalinski0 Jul 21, 2025
ba94768
Improved the performence of status translation by limiting report gua…
jakubkalinski0 Jul 21, 2025
04af12f
Commit after prettier run
jakubkalinski0 Jul 21, 2025
54d11c5
Added missing stateNum to CONST
jakubkalinski0 Jul 21, 2025
8c6292a
Added proper checks for all the state/status pairs in the getReportSt…
jakubkalinski0 Jul 21, 2025
ce500b5
Commit afted prettier run in ReportUtils.ts
jakubkalinski0 Jul 21, 2025
2f75a6d
Removed total from the bottom button
jakubkalinski0 Jul 21, 2025
63e99cb
Added unit tests for getReportStatusTranslation function
jakubkalinski0 Jul 21, 2025
8af16d5
Commit after prettier run in ReportUtilsTest.ts
jakubkalinski0 Jul 21, 2025
83072bb
Added AUTOREIMBURSED to the spellcheck
jakubkalinski0 Jul 21, 2025
7ad157c
Removed workaround for icon padding at the end of report preview name
jakubkalinski0 Jul 22, 2025
61d2a65
Fixed subheader alignment on mobile
jakubkalinski0 Jul 22, 2025
c974c03
Fixed wrapping on overflowing report preview name
jakubkalinski0 Jul 22, 2025
ba7a270
Added flexshrink1 to another container wrapping title
jakubkalinski0 Jul 22, 2025
bdda448
Small changes for better code quality and fixed empty space before st…
jakubkalinski0 Jul 23, 2025
7c1f2ab
Prettier run
jakubkalinski0 Jul 23, 2025
55b6110
Fixed typo
jakubkalinski0 Jul 23, 2025
6c2d83b
Properly fixed typo in margin
jakubkalinski0 Jul 23, 2025
173f4de
Improved efficiency of getReportStatusTranslation as proposed by @mou…
jakubkalinski0 Jul 25, 2025
198c9ca
Adjusted the tests to the changes in getReportStatusTranslation
jakubkalinski0 Jul 25, 2025
b261861
Fixed getReportStatusTranslation function to properly hangle undefine…
jakubkalinski0 Jul 25, 2025
a61d1d7
Added comment to clarify icon occurrence
jakubkalinski0 Jul 25, 2025
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
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"autofilled",
"automations",
"autoplay",
"AUTOREIMBURSED",
"autoreleasepool",
"AUTOREPORTING",
"autoresizesSubviews",
Expand Down
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,7 @@ const CONST = {
SUBMITTED: 1,
APPROVED: 2,
BILLING: 3,
AUTOREIMBURSED: 6,
},
STATUS_NUM: {
OPEN: 0,
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations = {
tax: 'Steuer',
shared: 'Geteilt',
drafts: 'Entwürfe',
draft: 'Entwurf',
finished: 'Fertiggestellt',
upgrade: 'Upgrade',
downgradeWorkspace: 'Arbeitsbereich herabstufen',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ const translations = {
tax: 'Tax',
shared: 'Shared',
drafts: 'Drafts',
draft: 'Draft',
finished: 'Finished',
upgrade: 'Upgrade',
downgradeWorkspace: 'Downgrade workspace',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ const translations = {
tax: 'Impuesto',
shared: 'Compartidos',
drafts: 'Borradores',
draft: 'Borrador',
finished: 'Finalizados',
upgrade: 'Mejora',
downgradeWorkspace: 'Desmejora tu espacio de trabajo',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations = {
tax: 'Taxe',
shared: 'Partagé',
drafts: 'Brouillons',
draft: 'Brouillon',
finished: 'Terminé',
upgrade: 'Mise à niveau',
downgradeWorkspace: "Rétrograder l'espace de travail",
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations = {
tax: 'Tassa',
shared: 'Condiviso',
drafts: 'Bozze',
draft: 'Bozza',
finished: 'Finito',
upgrade: 'Aggiorna',
downgradeWorkspace: 'Declassa spazio di lavoro',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations = {
tax: '税金',
shared: '共有',
drafts: '下書き',
draft: 'ドラフト',
finished: '完了',
upgrade: 'アップグレード',
downgradeWorkspace: 'ワークスペースをダウングレードする',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations = {
tax: 'Belasting',
shared: 'Gedeeld',
drafts: 'Concepten',
draft: 'Ontwerp',
finished: 'Voltooid',
upgrade: 'Upgrade',
downgradeWorkspace: 'Werkruimte downgraden',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations = {
tax: 'Podatek',
shared: 'Udostępnione',
drafts: 'Szkice',
draft: 'Szkic',
finished: 'Zakończono',
upgrade: 'Ulepszanie',
downgradeWorkspace: 'Obniż poziom przestrzeni roboczej',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations = {
tax: 'Imposto',
shared: 'Compartilhado',
drafts: 'Rascunhos',
draft: 'Rascunho',
finished: 'Concluído',
upgrade: 'Atualizar',
downgradeWorkspace: 'Reduzir espaço de trabalho',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations = {
tax: '税务',
shared: '共享',
drafts: '草稿',
draft: '草稿',
finished: '完成',
upgrade: '升级',
downgradeWorkspace: '降级工作区',
Expand Down
44 changes: 44 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@
callback: (value) => {
conciergeReportID = value;
},
});

Check warning on line 893 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({
Expand All @@ -898,7 +898,7 @@
callback: (value) => {
// When signed out, val is undefined
if (!value) {
return;

Check warning on line 901 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
}

currentUserEmail = value.email;
Expand All @@ -916,7 +916,7 @@
callback: (value) => {
if (currentUserAccountID) {
currentUserPersonalDetails = value?.[currentUserAccountID] ?? undefined;
}

Check warning on line 919 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
allPersonalDetails = value ?? {};
allPersonalDetailLogins = Object.values(allPersonalDetails).map((personalDetail) => personalDetail?.login ?? '');
},
Expand All @@ -928,14 +928,14 @@
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
});

Check warning on line 931 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
let allPolicies: OnyxCollection<Policy>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
});

Check warning on line 938 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
Onyx.connect({
Expand All @@ -943,7 +943,7 @@
waitForCollectionCallback: true,
callback: (value) => {
allReports = value;
UnreadIndicatorUpdaterHelper().then((module) => {

Check warning on line 946 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
module.triggerUnreadUpdate();
});

Expand Down Expand Up @@ -984,14 +984,14 @@
callback: (value) => (allBetas = value),
});

let allTransactions: OnyxCollection<Transaction> = {};

Check warning on line 987 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
let reportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
if (!value) {
return;

Check warning on line 994 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
}
allTransactions = Object.fromEntries(Object.entries(value).filter(([, transaction]) => transaction));

Expand All @@ -1017,7 +1017,7 @@
waitForCollectionCallback: true,
callback: (actions) => {
if (!actions) {
return;

Check warning on line 1020 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
}
allReportActions = actions;
},
Expand All @@ -1030,7 +1030,7 @@
waitForCollectionCallback: true,
callback: (value) => {
if (!value) {
return;

Check warning on line 1033 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
}
allReportMetadata = value;

Expand Down Expand Up @@ -11125,6 +11125,49 @@
return getReportName(iouReport) || action.childReportName;
}

/**
* Returns the translated, human-readable status of the report based on its state and status values.
* The status is determined by the stateNum and statusNum of the report.
* The mapping is as follows:
* ========================================
* State | Status | What to display? |
* 0 | 0 | Draft |
* 1 | 1 | Outstanding |
* 2 | 2 | Done |
* 2 | 3 | Approved |
* 2 | 4 | Paid |
* 3 | 4 | Paid |
Comment thread
jakubkalinski0 marked this conversation as resolved.
* 6 | 4 | Paid |
* ========================================
*/
function getReportStatusTranslation(stateNum?: number, statusNum?: number): string {
if (stateNum === undefined || statusNum === undefined) {
return '';
}

if (stateNum === CONST.REPORT.STATE_NUM.OPEN && statusNum === CONST.REPORT.STATUS_NUM.OPEN) {
return translateLocal('common.draft');
}
if (stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED) {
return translateLocal('common.outstanding');
}
if (stateNum === CONST.REPORT.STATE_NUM.APPROVED && statusNum === CONST.REPORT.STATUS_NUM.CLOSED) {
return translateLocal('common.done');
}
if (stateNum === CONST.REPORT.STATE_NUM.APPROVED && statusNum === CONST.REPORT.STATUS_NUM.APPROVED) {
return translateLocal('iou.approved');
}
if (
(stateNum === CONST.REPORT.STATE_NUM.APPROVED && statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED) ||
(stateNum === CONST.REPORT.STATE_NUM.BILLING && statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED) ||
(stateNum === CONST.REPORT.STATE_NUM.AUTOREIMBURSED && statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED)
) {
return translateLocal('iou.settledExpensify');
Comment thread
jakubkalinski0 marked this conversation as resolved.
}

return '';
}

export {
addDomainToShortMention,
completeShortMention,
Expand Down Expand Up @@ -11504,6 +11547,7 @@
getNextApproverAccountID,
isWorkspaceTaskReport,
isWorkspaceThread,
getReportStatusTranslation,
};

export type {
Expand Down
37 changes: 37 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
getReasonAndReportActionThatRequiresAttention,
getReportIDFromLink,
getReportName,
getReportStatusTranslation,
getWorkspaceIcon,
getWorkspaceNameUpdatedMessage,
hasReceiptError,
Expand Down Expand Up @@ -4719,4 +4720,40 @@ describe('ReportUtils', () => {
});
});
});

describe('getReportStatusTranslation', () => {
it('should return "Draft" for state 0, status 0', () => {
expect(getReportStatusTranslation(CONST.REPORT.STATE_NUM.OPEN, CONST.REPORT.STATUS_NUM.OPEN)).toBe(translateLocal('common.draft'));
});

it('should return "Outstanding" for state 1, status 1', () => {
expect(getReportStatusTranslation(CONST.REPORT.STATE_NUM.SUBMITTED, CONST.REPORT.STATUS_NUM.SUBMITTED)).toBe(translateLocal('common.outstanding'));
});

it('should return "Done" for state 2, status 2', () => {
expect(getReportStatusTranslation(CONST.REPORT.STATE_NUM.APPROVED, CONST.REPORT.STATUS_NUM.CLOSED)).toBe(translateLocal('common.done'));
});

it('should return "Approved" for state 2, status 3', () => {
expect(getReportStatusTranslation(CONST.REPORT.STATE_NUM.APPROVED, CONST.REPORT.STATUS_NUM.APPROVED)).toBe(translateLocal('iou.approved'));
});

it('should return "Paid" for state 2, status 4', () => {
expect(getReportStatusTranslation(CONST.REPORT.STATE_NUM.APPROVED, CONST.REPORT.STATUS_NUM.REIMBURSED)).toBe(translateLocal('iou.settledExpensify'));
});

it('should return "Paid" for state 3, status 4', () => {
expect(getReportStatusTranslation(CONST.REPORT.STATE_NUM.BILLING, CONST.REPORT.STATUS_NUM.REIMBURSED)).toBe(translateLocal('iou.settledExpensify'));
});

it('should return "Paid" for state 6, status 4', () => {
expect(getReportStatusTranslation(CONST.REPORT.STATE_NUM.AUTOREIMBURSED, CONST.REPORT.STATUS_NUM.REIMBURSED)).toBe(translateLocal('iou.settledExpensify'));
});

it('should return an empty string when stateNum or statusNum is undefined', () => {
expect(getReportStatusTranslation(undefined, undefined)).toBe('');
expect(getReportStatusTranslation(CONST.REPORT.STATE_NUM.OPEN, undefined)).toBe('');
expect(getReportStatusTranslation(undefined, CONST.REPORT.STATUS_NUM.OPEN)).toBe('');
});
});
});
Loading