Skip to content

Commit f1ec9fe

Browse files
Merge branch 'Expensify:main' into fix/64976-cards-filter-with-old-ui
2 parents 3876e7e + 70224c4 commit f1ec9fe

8 files changed

Lines changed: 69 additions & 18 deletions

File tree

Mobile-Expensify

src/components/TransactionItemRow/DataCells/CategoryCell.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ import * as Expensicons from '@components/Icon/Expensicons';
33
import TextWithIconCell from '@components/SelectionList/Search/TextWithIconCell';
44
import TextWithTooltip from '@components/TextWithTooltip';
55
import useThemeStyles from '@hooks/useThemeStyles';
6-
import CONST from '@src/CONST';
6+
import {isCategoryMissing} from '@libs/CategoryUtils';
77
import type TransactionDataCellProps from './TransactionDataCellProps';
88

99
function CategoryCell({shouldUseNarrowLayout, shouldShowTooltip, transactionItem}: TransactionDataCellProps) {
1010
const styles = useThemeStyles();
1111

12-
const emptyCategories = CONST.SEARCH.CATEGORY_EMPTY_VALUE.split(',');
13-
14-
const category = transactionItem?.category ?? '';
15-
const categoryForDisplay = emptyCategories.includes(category) ? '' : category;
12+
const categoryForDisplay = isCategoryMissing(transactionItem?.category) ? '' : (transactionItem?.category ?? '');
1613

1714
return shouldUseNarrowLayout ? (
1815
<TextWithIconCell

src/components/TransactionItemRow/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import useLocalize from '@hooks/useLocalize';
1717
import useStyleUtils from '@hooks/useStyleUtils';
1818
import useTheme from '@hooks/useTheme';
1919
import useThemeStyles from '@hooks/useThemeStyles';
20+
import {isCategoryMissing} from '@libs/CategoryUtils';
2021
import Parser from '@libs/Parser';
2122
import StringUtils from '@libs/StringUtils';
2223
import {
@@ -25,10 +26,9 @@ import {
2526
getCreated as getTransactionCreated,
2627
getTransactionPendingAction,
2728
hasMissingSmartscanFields,
28-
hasReceipt,
2929
isAmountMissing,
3030
isMerchantMissing,
31-
isReceiptBeingScanned,
31+
isScanning,
3232
isTransactionPendingDelete,
3333
} from '@libs/TransactionUtils';
3434
import variables from '@styles/variables';
@@ -112,11 +112,13 @@ function getMerchantNameWithFallback(transactionItem: TransactionWithOptionalSea
112112
if (merchantNameEmpty && shouldUseNarrowLayout) {
113113
merchantOrDescriptionToDisplay = Parser.htmlToText(description);
114114
}
115+
115116
let merchant = shouldShowMerchant ? merchantOrDescriptionToDisplay : Parser.htmlToText(description);
116117

117-
if (hasReceipt(transactionItem) && isReceiptBeingScanned(transactionItem) && shouldShowMerchant) {
118+
if (isScanning(transactionItem) && shouldShowMerchant) {
118119
merchant = translate('iou.receiptStatusTitle');
119120
}
121+
120122
const merchantName = StringUtils.getFirstLine(merchant);
121123
return merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? merchantName : '';
122124
}
@@ -149,7 +151,7 @@ function TransactionItemRow({
149151
const isPendingDelete = isTransactionPendingDelete(transactionItem);
150152
const viewRef = useRef<View>(null);
151153

152-
const hasCategoryOrTag = !!transactionItem.category || !!transactionItem.tag;
154+
const hasCategoryOrTag = !isCategoryMissing(transactionItem?.category) || !!transactionItem.tag;
153155
const createdAt = getTransactionCreated(transactionItem);
154156

155157
const isDateColumnWide = dateColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE;

src/libs/API/parameters/CreateWorkspaceFromIOUPaymentParams.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type CreateWorkspaceFromIOUPaymentParams = {
1313
iouReportID: string;
1414
memberData: string;
1515
reportActionID: string | undefined;
16+
expenseMovedReportActionID: string | undefined;
1617
};
1718

1819
export default CreateWorkspaceFromIOUPaymentParams;

src/libs/CategoryUtils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ function getEnabledCategoriesCount(policyCategories: PolicyCategories | undefine
9393
return Object.values(policyCategories).filter((policyCategory) => policyCategory.enabled).length;
9494
}
9595

96+
function isCategoryMissing(category: string | undefined): boolean {
97+
if (!category) {
98+
return true;
99+
}
100+
const emptyCategories = CONST.SEARCH.CATEGORY_EMPTY_VALUE.split(',');
101+
102+
return emptyCategories.includes(category ?? '');
103+
}
104+
96105
export {
97106
formatDefaultTaxRateText,
98107
formatRequireReceiptsOverText,
@@ -101,4 +110,5 @@ export {
101110
getCategoryDefaultTaxRate,
102111
updateCategoryInMccGroup,
103112
getEnabledCategoriesCount,
113+
isCategoryMissing,
104114
};

src/libs/ReportUtils.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,7 +3236,7 @@ function getIconsForInvoiceReport(
32363236
*/
32373237
function getIcons(
32383238
report: OnyxInputOrEntry<Report>,
3239-
personalDetails: OnyxInputOrEntry<PersonalDetailsList>,
3239+
personalDetails: OnyxInputOrEntry<PersonalDetailsList> = allPersonalDetails,
32403240
defaultIcon: AvatarSource | null = null,
32413241
defaultName = '',
32423242
defaultAccountID = -1,
@@ -6388,7 +6388,14 @@ function buildOptimisticUnapprovedReportAction(amount: number, currency: string,
63886388
* Builds an optimistic MOVED report action with a randomly generated reportActionID.
63896389
* This action is used when we move reports across workspaces.
63906390
*/
6391-
function buildOptimisticMovedReportAction(fromPolicyID: string | undefined, toPolicyID: string, newParentReportID: string, movedReportID: string, policyName: string): ReportAction {
6391+
function buildOptimisticMovedReportAction(
6392+
fromPolicyID: string | undefined,
6393+
toPolicyID: string,
6394+
newParentReportID: string,
6395+
movedReportID: string,
6396+
policyName: string,
6397+
isIouReport = false,
6398+
): ReportAction {
63926399
const originalMessage = {
63936400
fromPolicyID,
63946401
toPolicyID,
@@ -6398,8 +6405,10 @@ function buildOptimisticMovedReportAction(fromPolicyID: string | undefined, toPo
63986405

63996406
const movedActionMessage = [
64006407
{
6401-
html: `moved the report to the <a href='${CONST.NEW_EXPENSIFY_URL}r/${newParentReportID}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace`,
6402-
text: `moved the report to the ${policyName} workspace`,
6408+
html: isIouReport
6409+
? `moved this <a href='${CONST.NEW_EXPENSIFY_URL}r/${movedReportID}' target='_blank' rel='noreferrer noopener'>report</a> to the <a href='${CONST.NEW_EXPENSIFY_URL}r/${newParentReportID}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace`
6410+
: `moved this report to the <a href='${CONST.NEW_EXPENSIFY_URL}r/${newParentReportID}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace`,
6411+
text: `moved this report to the ${policyName} workspace`,
64036412
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
64046413
},
64056414
];

src/libs/actions/Policy/Policy.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2969,7 +2969,33 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceF
29692969
}
29702970

29712971
// Create the MOVED report action and add it to the DM chat which indicates to the user where the report has been moved
2972-
const movedReportAction = ReportUtils.buildOptimisticMovedReportAction(oldPersonalPolicyID, policyID, memberData.workspaceChatReportID, iouReportID, workspaceName);
2972+
const movedReportAction = ReportUtils.buildOptimisticMovedReportAction(oldPersonalPolicyID, policyID, memberData.workspaceChatReportID, iouReportID, workspaceName, true);
2973+
2974+
const movedIouReportAction = ReportUtils.buildOptimisticMovedReportAction(oldPersonalPolicyID, policyID, memberData.workspaceChatReportID, iouReportID, workspaceName);
2975+
2976+
optimisticData.push({
2977+
onyxMethod: Onyx.METHOD.MERGE,
2978+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`,
2979+
value: {[movedIouReportAction.reportActionID]: movedIouReportAction},
2980+
});
2981+
2982+
successData.push({
2983+
onyxMethod: Onyx.METHOD.MERGE,
2984+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`,
2985+
value: {
2986+
[movedIouReportAction.reportActionID]: {
2987+
...movedIouReportAction,
2988+
pendingAction: null,
2989+
},
2990+
},
2991+
});
2992+
2993+
failureData.push({
2994+
onyxMethod: Onyx.METHOD.MERGE,
2995+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`,
2996+
value: {[movedIouReportAction.reportActionID]: null},
2997+
});
2998+
29732999
optimisticData.push({
29743000
onyxMethod: Onyx.METHOD.MERGE,
29753001
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${oldChatReportID}`,
@@ -3026,6 +3052,7 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceF
30263052
iouReportID,
30273053
memberData: JSON.stringify(memberData),
30283054
reportActionID: movedReportAction.reportActionID,
3055+
expenseMovedReportActionID: movedIouReportAction.reportActionID,
30293056
};
30303057

30313058
API.write(WRITE_COMMANDS.CREATE_WORKSPACE_FROM_IOU_PAYMENT, params, {optimisticData, successData, failureData});

src/pages/iou/request/step/IOURequestStepParticipants.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {useOnyx} from 'react-native-onyx';
44
import FormHelpMessage from '@components/FormHelpMessage';
55
import useLocalize from '@hooks/useLocalize';
66
import useThemeStyles from '@hooks/useThemeStyles';
7+
import {setTransactionReport} from '@libs/actions/Transaction';
78
import {READ_COMMANDS} from '@libs/API/types';
89
import {isMobileSafari as isMobileSafariBrowser} from '@libs/Browser';
910
import DistanceRequestUtils from '@libs/DistanceRequestUtils';
@@ -12,7 +13,7 @@ import HttpUtils from '@libs/HttpUtils';
1213
import {isMovingTransactionFromTrackExpense as isMovingTransactionFromTrackExpenseIOUUtils, navigateToStartMoneyRequestStep} from '@libs/IOUUtils';
1314
import Navigation from '@libs/Navigation/Navigation';
1415
import Performance from '@libs/Performance';
15-
import {findSelfDMReportID, isInvoiceRoomWithID} from '@libs/ReportUtils';
16+
import {findSelfDMReportID, generateReportID, isInvoiceRoomWithID} from '@libs/ReportUtils';
1617
import {getRequestType, isPerDiemRequest} from '@libs/TransactionUtils';
1718
import MoneyRequestParticipantsSelector from '@pages/iou/request/MoneyRequestParticipantsSelector';
1819
import {
@@ -198,7 +199,7 @@ function IOURequestStepParticipants({
198199
}
199200

200201
// When a participant is selected, the reportID needs to be saved because that's the reportID that will be used in the confirmation step.
201-
selectedReportID.current = firstParticipantReportID ?? reportID;
202+
selectedReportID.current = firstParticipantReportID ?? generateReportID();
202203
},
203204
[iouType, transactions, isMovingTransactionFromTrackExpense, reportID, trackExpense],
204205
);
@@ -213,9 +214,13 @@ function IOURequestStepParticipants({
213214
setSplitShares(initialTransaction, initialTransaction.amount, initialTransaction.currency, participantAccountIDs);
214215
}
215216

217+
const newReportID = selectedReportID.current;
216218
transactions.forEach((transaction) => {
217219
setMoneyRequestTag(transaction.transactionID, '');
218220
setMoneyRequestCategory(transaction.transactionID, '');
221+
if (participants?.at(0)?.reportID !== newReportID) {
222+
setTransactionReport(transaction.transactionID, newReportID, true);
223+
}
219224
});
220225
if ((isCategorizing || isShareAction) && numberOfParticipants.current === 0) {
221226
const {expenseChatReportID, policyID, policyName} = createDraftWorkspace();
@@ -245,7 +250,7 @@ function IOURequestStepParticipants({
245250
action,
246251
iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType,
247252
initialTransactionID,
248-
selectedReportID.current || reportID,
253+
newReportID,
249254
);
250255

251256
const route = isCategorizing

0 commit comments

Comments
 (0)