Skip to content

Commit ce76e87

Browse files
authored
Merge pull request #60179 from software-mansion-labs/korytko/follow-ups-leftovers
[No QA] [Better Expense Report View] Clean up remaining nested follow-ups & added code
2 parents b9ac650 + 744d141 commit ce76e87

16 files changed

+479
-424
lines changed

.storybook/webpack.config.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import dotenv from 'dotenv';
88
import path from 'path';
99
import {DefinePlugin} from 'webpack';
1010
import type {Configuration, RuleSetRule} from 'webpack';
11+
import webpackMockPaths from './webpackMockPaths';
1112

1213
type CustomWebpackConfig = {
1314
resolve: {
@@ -54,11 +55,7 @@ const webpackConfig = ({config}: {config: Configuration}) => {
5455
}
5556

5657
config.resolve.alias = {
57-
'react-native-config': 'react-web-config',
58-
'react-native$': 'react-native-web',
59-
'@react-native-community/netinfo': path.resolve(__dirname, '../__mocks__/@react-native-community/netinfo.ts'),
60-
'@react-navigation/native': path.resolve(__dirname, '../__mocks__/@react-navigation/native'),
61-
'@libs/TransactionPreviewUtils': path.resolve(__dirname, '../src/libs/__mocks__/TransactionPreviewUtils.ts'),
58+
...webpackMockPaths,
6259
...custom.resolve.alias,
6360
};
6461

.storybook/webpackMockPaths.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import path from 'path';
2+
3+
/* eslint-disable @typescript-eslint/naming-convention */
4+
export default {
5+
'react-native-config': 'react-web-config',
6+
'react-native$': 'react-native-web',
7+
'@react-native-community/netinfo': path.resolve(__dirname, '../__mocks__/@react-native-community/netinfo.ts'),
8+
'@react-navigation/native': path.resolve(__dirname, '../__mocks__/@react-navigation/native'),
9+
'@libs/TransactionPreviewUtils': path.resolve(__dirname, '../src/libs/__mocks__/TransactionPreviewUtils.ts'),
10+
};
11+
/* eslint-enable @typescript-eslint/naming-convention */

__mocks__/reportData/actions.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import CONST from '@src/CONST';
2+
import type {OriginalMessageIOU, ReportAction} from '@src/types/onyx';
3+
4+
const usersIDs = [15593135, 51760358, 26502375];
5+
const amount = 10402;
6+
const currency = CONST.CURRENCY.USD;
7+
8+
const REPORT_R98765 = {
9+
IOUReportID: 'IOU_REPORT_ID_R98765',
10+
IOUTransactionID: 'TRANSACTION_ID_R98765',
11+
reportActionID: 'REPORT_ACTION_ID_R98765',
12+
childReportID: 'CHILD_REPORT_ID_R98765',
13+
};
14+
15+
const REPORT_R14932 = {
16+
IOUReportID: 'IOU_REPORT_ID_R14932',
17+
IOUTransactionID: 'TRANSACTION_ID_R14932',
18+
reportActionID: 'REPORT_ACTION_ID_R14932',
19+
childReportID: 'CHILD_REPORT_ID_R14932',
20+
};
21+
22+
const originalMessageR14932: OriginalMessageIOU = {
23+
currency,
24+
amount,
25+
IOUReportID: REPORT_R14932.IOUReportID,
26+
IOUTransactionID: REPORT_R14932.IOUTransactionID,
27+
participantAccountIDs: usersIDs,
28+
type: CONST.IOU.TYPE.CREATE,
29+
lastModified: '2025-02-14 08:12:05.165',
30+
comment: '',
31+
};
32+
33+
const message = [
34+
{
35+
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
36+
html: '$0.01 expense',
37+
text: '$0.01 expense',
38+
isEdited: false,
39+
whisperedTo: [],
40+
isDeletedParentAction: false,
41+
deleted: '',
42+
},
43+
];
44+
45+
const person = [
46+
{
47+
type: 'TEXT',
48+
style: 'strong',
49+
text: 'John Smith',
50+
},
51+
];
52+
53+
const actionR14932: ReportAction = {
54+
person,
55+
message,
56+
reportActionID: REPORT_R14932.reportActionID,
57+
childReportID: REPORT_R14932.childReportID,
58+
originalMessage: originalMessageR14932,
59+
actorAccountID: usersIDs.at(0),
60+
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
61+
childType: CONST.REPORT.TYPE.CHAT,
62+
childReportName: 'Expense #R14932',
63+
created: '2025-02-14 08:12:05.165',
64+
};
65+
66+
const originalMessageR98765: OriginalMessageIOU = {
67+
amount,
68+
currency,
69+
IOUReportID: REPORT_R98765.IOUReportID,
70+
IOUTransactionID: REPORT_R98765.IOUTransactionID,
71+
participantAccountIDs: usersIDs,
72+
type: CONST.IOU.TYPE.CREATE,
73+
comment: '',
74+
lastModified: '2025-02-20 08:10:05.165',
75+
};
76+
77+
const actionR98765: ReportAction = {
78+
message,
79+
person,
80+
reportActionID: REPORT_R98765.reportActionID,
81+
childReportID: REPORT_R98765.childReportID,
82+
originalMessage: originalMessageR98765,
83+
actorAccountID: usersIDs.at(0),
84+
childType: CONST.REPORT.TYPE.CHAT,
85+
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
86+
created: '2025-02-14 08:12:05.165',
87+
};
88+
89+
export {actionR14932, actionR98765};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import type {PersonalDetailsList} from '@src/types/onyx';
2+
3+
const usersIDs = [15593135, 51760358, 26502375] as const;
4+
5+
const personalDetails: PersonalDetailsList = {
6+
[usersIDs[0]]: {
7+
accountID: usersIDs[0],
8+
avatar: '@assets/images/avatars/user/default-avatar_1.svg',
9+
firstName: 'John',
10+
lastName: 'Smith',
11+
status: {
12+
clearAfter: '',
13+
emojiCode: '🚲',
14+
text: '0% cycling in Canary islands',
15+
},
16+
displayName: 'John Smith',
17+
18+
pronouns: '__predefined_heHimHis',
19+
timezone: {
20+
automatic: true,
21+
selected: 'Europe/Luxembourg',
22+
},
23+
phoneNumber: '11111111',
24+
validated: true,
25+
},
26+
[usersIDs[1]]: {
27+
accountID: usersIDs[1],
28+
avatar: '@assets/images/avatars/user/default-avatar_2.svg',
29+
firstName: 'Ted',
30+
lastName: 'Kowalski',
31+
status: {
32+
clearAfter: '',
33+
emojiCode: '🚲',
34+
text: '0% cycling in Canary islands',
35+
},
36+
displayName: 'Ted Kowalski',
37+
38+
pronouns: '__predefined_heHimHis',
39+
timezone: {
40+
automatic: true,
41+
selected: 'Europe/Warsaw',
42+
},
43+
phoneNumber: '22222222',
44+
validated: true,
45+
},
46+
[usersIDs[2]]: {
47+
accountID: usersIDs[2],
48+
avatar: '@assets/images/avatars/user/default-avatar_3.svg',
49+
firstName: 'Jane',
50+
lastName: 'Doe',
51+
status: {
52+
clearAfter: '',
53+
emojiCode: '🚲',
54+
text: '0% cycling in Canary islands',
55+
},
56+
displayName: 'Jane Doe',
57+
58+
pronouns: '__predefined_sheHerHers',
59+
timezone: {
60+
automatic: true,
61+
selected: 'Europe/London',
62+
},
63+
phoneNumber: '33333333',
64+
validated: true,
65+
},
66+
};
67+
68+
export default personalDetails;

__mocks__/reportData/reports.ts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import CONST from '@src/CONST';
2+
import type {Report} from '@src/types/onyx';
3+
4+
const usersIDs = [15593135, 51760358, 26502375];
5+
const amount = 10402;
6+
const currency = CONST.CURRENCY.USD;
7+
8+
const REPORT_ID_R14932 = 'REPORT_ID_R14932';
9+
const CHAT_REPORT_ID_R14932 = 'CHAT_REPORT_ID_R14932';
10+
const IOU_REPORT_ID_R14932 = 'IOU_REPORT_ID_R14932';
11+
const PARENT_REPORT_ACTION_ID_R14932 = 'PARENT_ACTION_ID_R14932';
12+
const PARENT_REPORT_ID_R14932 = 'PARENT_REPORT_ID_R14932';
13+
const LAST_MESSAGE_R14932 = 'LAST_MESSAGE_R14932';
14+
15+
const participants = usersIDs.reduce((prev, userID) => {
16+
return {
17+
[userID]: {
18+
notificationPreference: 'always',
19+
},
20+
};
21+
}, {});
22+
23+
const iouReportR14932: Report = {
24+
currency,
25+
participants,
26+
total: amount,
27+
unheldTotal: amount,
28+
chatReportID: CHAT_REPORT_ID_R14932,
29+
lastMessageHtml: LAST_MESSAGE_R14932,
30+
lastMessageText: LAST_MESSAGE_R14932,
31+
parentReportActionID: PARENT_REPORT_ACTION_ID_R14932,
32+
parentReportID: PARENT_REPORT_ID_R14932,
33+
reportID: REPORT_ID_R14932,
34+
lastActorAccountID: usersIDs.at(0),
35+
ownerAccountID: usersIDs.at(0),
36+
managerID: usersIDs.at(1),
37+
permissions: [CONST.REPORT.PERMISSIONS.READ, CONST.REPORT.PERMISSIONS.WRITE],
38+
policyID: CONST.POLICY.ID_FAKE,
39+
reportName: CONST.REPORT.ACTIONS.TYPE.IOU,
40+
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
41+
statusNum: CONST.REPORT.STATUS_NUM.OPEN,
42+
type: CONST.REPORT.TYPE.EXPENSE,
43+
writeCapability: CONST.REPORT.WRITE_CAPABILITIES.ALL,
44+
lastActionType: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
45+
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
46+
hasOutstandingChildRequest: false,
47+
hasOutstandingChildTask: false,
48+
hasParentAccess: true,
49+
isCancelledIOU: false,
50+
isOwnPolicyExpenseChat: false,
51+
isPinned: false,
52+
isWaitingOnBankAccount: false,
53+
lastReadTime: '2025-03-07 07:23:39.335',
54+
lastVisibleActionCreated: '2025-03-07 07:23:39.335',
55+
lastVisibleActionLastModified: '2025-03-07 07:23:39.335',
56+
lastReadSequenceNumber: 0,
57+
unheldNonReimbursableTotal: 0,
58+
nonReimbursableTotal: 0,
59+
errorFields: {},
60+
welcomeMessage: '',
61+
description: '',
62+
oldPolicyName: '',
63+
};
64+
65+
const chatReportR14932: Report = {
66+
currency,
67+
participants,
68+
lastMessageText: LAST_MESSAGE_R14932,
69+
reportID: REPORT_ID_R14932,
70+
iouReportID: IOU_REPORT_ID_R14932,
71+
lastActorAccountID: usersIDs.at(0),
72+
ownerAccountID: usersIDs.at(0),
73+
managerID: usersIDs.at(1),
74+
total: amount,
75+
unheldTotal: amount,
76+
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
77+
policyID: CONST.POLICY.ID_FAKE,
78+
reportName: CONST.REPORT.DEFAULT_REPORT_NAME,
79+
lastActionType: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
80+
writeCapability: CONST.REPORT.WRITE_CAPABILITIES.ALL,
81+
permissions: [CONST.REPORT.PERMISSIONS.READ, CONST.REPORT.PERMISSIONS.WRITE],
82+
type: CONST.REPORT.TYPE.CHAT,
83+
lastMessageHtml: `<mention-user accountID="${usersIDs.at(0)}"/> <mention-user accountID="${usersIDs.at(0)}"/>`,
84+
lastReadTime: '2025-03-11 08:51:38.736',
85+
lastVisibleActionCreated: '2025-03-11 08:47:56.654',
86+
lastVisibleActionLastModified: '2025-03-11 08:47:56.654',
87+
hasOutstandingChildRequest: false,
88+
hasOutstandingChildTask: false,
89+
isCancelledIOU: false,
90+
isOwnPolicyExpenseChat: false,
91+
isPinned: false,
92+
isWaitingOnBankAccount: false,
93+
lastReadSequenceNumber: 0,
94+
unheldNonReimbursableTotal: 0,
95+
stateNum: 0,
96+
statusNum: 0,
97+
nonReimbursableTotal: 0,
98+
errorFields: {},
99+
description: '',
100+
oldPolicyName: '',
101+
welcomeMessage: '',
102+
};
103+
104+
export {chatReportR14932, iouReportR14932};

__mocks__/reportData/transactions.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import CONST from '@src/CONST';
2+
import type {Transaction} from '@src/types/onyx';
3+
4+
const amount = 10402;
5+
const currency = CONST.CURRENCY.USD;
6+
const REPORT_ID_R14932 = 'REPORT_ID_R14932';
7+
const TRANSACTION_ID_R14932 = 'TRANSACTION_ID_R14932';
8+
const REPORT_ID_R98765 = 'REPORT_ID_R98765';
9+
const TRANSACTION_ID_R98765 = 'TRANSACTION_ID_R98765';
10+
11+
const receiptR14932 = {
12+
state: CONST.IOU.RECEIPT_STATE.OPEN,
13+
source: 'mockData/eReceiptBGs/eReceiptBG_pink.png',
14+
};
15+
16+
const transactionR14932: Transaction = {
17+
amount,
18+
currency,
19+
cardName: CONST.EXPENSE.TYPE.CASH_CARD_NAME,
20+
transactionID: TRANSACTION_ID_R14932,
21+
reportID: REPORT_ID_R14932,
22+
status: CONST.TRANSACTION.STATUS.POSTED,
23+
receipt: receiptR14932,
24+
merchant: 'Acme',
25+
filename: 'test.html',
26+
created: '2025-02-14',
27+
inserted: '2025-02-14 08:12:19',
28+
billable: false,
29+
managedCard: false,
30+
reimbursable: true,
31+
hasEReceipt: true,
32+
cardID: 0,
33+
modifiedAmount: 0,
34+
originalAmount: 0,
35+
comment: {},
36+
bank: '',
37+
cardNumber: '',
38+
category: '',
39+
modifiedCreated: '',
40+
modifiedCurrency: '',
41+
modifiedMerchant: '',
42+
originalCurrency: '',
43+
parentTransactionID: '',
44+
posted: '',
45+
tag: '',
46+
};
47+
48+
const transactionR98765: Transaction = {
49+
currency,
50+
amount,
51+
transactionID: TRANSACTION_ID_R98765,
52+
reportID: REPORT_ID_R98765,
53+
status: CONST.TRANSACTION.STATUS.POSTED,
54+
cardName: CONST.EXPENSE.TYPE.CASH_CARD_NAME,
55+
created: '2025-02-14',
56+
inserted: '2025-02-14 08:12:19',
57+
merchant: 'Acme',
58+
reimbursable: true,
59+
hasEReceipt: true,
60+
managedCard: false,
61+
billable: false,
62+
modifiedAmount: 0,
63+
cardID: 0,
64+
originalAmount: 0,
65+
comment: {},
66+
bank: '',
67+
cardNumber: '',
68+
category: '',
69+
filename: '',
70+
modifiedCreated: '',
71+
modifiedCurrency: '',
72+
modifiedMerchant: '',
73+
originalCurrency: '',
74+
parentTransactionID: '',
75+
posted: '',
76+
tag: '',
77+
};
78+
79+
export {transactionR14932, transactionR98765};

0 commit comments

Comments
 (0)