Skip to content

Commit 580ba24

Browse files
committed
Merge branch 'main' into 69562-fix-localization-dates-not-being-localized-correctly
2 parents 62523a1 + b241944 commit 580ba24

14 files changed

Lines changed: 41 additions & 50 deletions

File tree

src/components/MoneyReportHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ function MoneyReportHeader({
11961196
Navigation.goBack(route.params?.backTo);
11971197
// eslint-disable-next-line @typescript-eslint/no-deprecated
11981198
InteractionManager.runAfterInteractions(() => {
1199-
deleteAppReport(moneyRequestReport?.reportID);
1199+
deleteAppReport(moneyRequestReport?.reportID, email ?? '');
12001200
});
12011201
},
12021202
},

src/components/ReportActionItem/TransactionPreview/TransactionPreviewContent.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ReportActionItemImages from '@components/ReportActionItem/ReportActionIte
1111
import UserInfoCellsWithArrow from '@components/SelectionListWithSections/Search/UserInfoCellsWithArrow';
1212
import Text from '@components/Text';
1313
import TransactionPreviewSkeletonView from '@components/TransactionPreviewSkeletonView';
14+
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
1415
import useEnvironment from '@hooks/useEnvironment';
1516
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
1617
import useLocalize from '@hooks/useLocalize';
@@ -82,7 +83,7 @@ function TransactionPreviewContent({
8283
const isReportAPolicyExpenseChat = isPolicyExpenseChat(chatReport);
8384
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(report?.reportID)}`, {canBeMissing: true});
8485
const isChatReportArchived = useReportIsArchived(chatReport?.reportID);
85-
86+
const currentUserDetails = useCurrentUserPersonalDetails();
8687
const transactionPreviewCommonArguments = useMemo(
8788
() => ({
8889
iouReport: report,
@@ -101,8 +102,9 @@ function TransactionPreviewContent({
101102
...transactionPreviewCommonArguments,
102103
areThereDuplicates,
103104
isReportAPolicyExpenseChat,
105+
currentUserEmail: currentUserDetails.email ?? '',
104106
}),
105-
[areThereDuplicates, transactionPreviewCommonArguments, isReportAPolicyExpenseChat],
107+
[areThereDuplicates, transactionPreviewCommonArguments, isReportAPolicyExpenseChat, currentUserDetails.email],
106108
);
107109

108110
const {shouldShowRBR, shouldShowMerchant, shouldShowSplitShare, shouldShowTag, shouldShowCategory, shouldShowSkeleton, shouldShowDescription} = conditionals;
@@ -120,10 +122,11 @@ function TransactionPreviewContent({
120122
shouldShowRBR,
121123
violationMessage,
122124
reportActions,
125+
currentUserEmail: currentUserDetails.email ?? '',
123126
originalTransaction,
124127
locale: preferredLocale,
125128
}),
126-
[transactionPreviewCommonArguments, shouldShowRBR, violationMessage, reportActions, originalTransaction, preferredLocale],
129+
[transactionPreviewCommonArguments, shouldShowRBR, violationMessage, reportActions, currentUserDetails.email, originalTransaction, preferredLocale],
127130
);
128131
const getTranslatedText = (item: TranslationPathOrText) => (item.translationPath ? translate(item.translationPath) : (item.text ?? ''));
129132

src/libs/PersonalDetailsUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function getPersonalDetailsByIDs({
117117
personalDetailsParam = allPersonalDetails,
118118
}: {
119119
accountIDs: number[];
120-
currentUserAccountID: number;
120+
currentUserAccountID?: number;
121121
shouldChangeUserDisplayName?: boolean;
122122
personalDetailsParam?: Partial<PersonalDetailsList>;
123123
}): PersonalDetails[] {

src/libs/ReportUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,7 +2763,7 @@ function isMoneyRequestReportEligibleForMerge(reportID: string, isAdmin: boolean
27632763
return isManager && isExpenseReport(report) && isProcessingReport(report);
27642764
}
27652765

2766-
function hasOutstandingChildRequest(chatReport: Report, iouReportOrID: OnyxEntry<Report> | string) {
2766+
function hasOutstandingChildRequest(chatReport: Report, iouReportOrID: OnyxEntry<Report> | string, currentUserEmailParam: string) {
27672767
const reportActions = getAllReportActions(chatReport.reportID);
27682768
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
27692769
// eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -2782,7 +2782,9 @@ function hasOutstandingChildRequest(chatReport: Report, iouReportOrID: OnyxEntry
27822782
const iouReport = typeof iouReportOrID !== 'string' && iouReportOrID?.reportID === iouReportID ? iouReportOrID : getReportOrDraftReport(iouReportID);
27832783
const transactions = getReportTransactions(iouReportID);
27842784
return (
2785-
canIOUBePaid(iouReport, chatReport, policy, transactions) || canApproveIOU(iouReport, policy, transactions) || canSubmitReport(iouReport, policy, transactions, undefined, false)
2785+
canIOUBePaid(iouReport, chatReport, policy, transactions) ||
2786+
canApproveIOU(iouReport, policy, transactions) ||
2787+
canSubmitReport(iouReport, policy, transactions, undefined, false, currentUserEmailParam)
27862788
);
27872789
});
27882790
}

src/libs/SearchUIUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ function getActions(
13291329
}
13301330

13311331
// We check for isAllowedToApproveExpenseReport because if the policy has preventSelfApprovals enabled, we disable the Submit action and in that case we want to show the View action instead
1332-
if (canSubmitReport(report, policy, allReportTransactions, allViolations, isIOUReportArchived || isChatReportArchived) && isAllowedToApproveExpenseReport) {
1332+
if (canSubmitReport(report, policy, allReportTransactions, allViolations, isIOUReportArchived || isChatReportArchived, currentUserEmail) && isAllowedToApproveExpenseReport) {
13331333
allActions.push(CONST.SEARCH.ACTION_TYPES.SUBMIT);
13341334
}
13351335

src/libs/TransactionPreviewUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {abandonReviewDuplicateTransactions, setReviewDuplicatesKey} from './acti
1111
import {isCategoryMissing} from './CategoryUtils';
1212
import {convertToDisplayString} from './CurrencyUtils';
1313
import DateUtils from './DateUtils';
14-
import {getCurrentUserEmail} from './Network/NetworkStore';
1514
import {getPolicy} from './PolicyUtils';
1615
import {getOriginalMessage, isMessageDeleted, isMoneyRequestAction} from './ReportActionsUtils';
1716
import {
@@ -189,6 +188,7 @@ function getTransactionPreviewTextAndTranslationPaths({
189188
shouldShowRBR,
190189
violationMessage,
191190
reportActions,
191+
currentUserEmail,
192192
originalTransaction,
193193
locale,
194194
}: {
@@ -201,6 +201,7 @@ function getTransactionPreviewTextAndTranslationPaths({
201201
shouldShowRBR: boolean;
202202
violationMessage?: string;
203203
reportActions?: OnyxTypes.ReportActions;
204+
currentUserEmail: string;
204205
originalTransaction?: OnyxEntry<OnyxTypes.Transaction>;
205206
locale?: Locale;
206207
}) {
@@ -217,7 +218,6 @@ function getTransactionPreviewTextAndTranslationPaths({
217218
const isTransactionScanning = isScanning(transaction);
218219
const hasFieldErrors = hasMissingSmartscanFields(transaction);
219220
const isPaidGroupPolicy = isPaidGroupPolicyUtil(iouReport);
220-
const currentUserEmail = getCurrentUserEmail();
221221

222222
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
223223
// eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -354,6 +354,7 @@ function createTransactionPreviewConditionals({
354354
isBillSplit,
355355
isReportAPolicyExpenseChat,
356356
areThereDuplicates,
357+
currentUserEmail,
357358
}: {
358359
iouReport: OnyxInputValue<OnyxTypes.Report> | undefined;
359360
transaction: OnyxEntry<OnyxTypes.Transaction> | undefined;
@@ -363,6 +364,7 @@ function createTransactionPreviewConditionals({
363364
isBillSplit: boolean;
364365
isReportAPolicyExpenseChat: boolean;
365366
areThereDuplicates: boolean;
367+
currentUserEmail: string;
366368
}) {
367369
const {amount: requestAmount, comment: requestComment, merchant, tag, category} = transactionDetails;
368370

@@ -373,8 +375,6 @@ function createTransactionPreviewConditionals({
373375
const isApproved = isReportApproved({report: iouReport});
374376
const isSettlementOrApprovalPartial = !!iouReport?.pendingFields?.partial;
375377

376-
const currentUserEmail = getCurrentUserEmail();
377-
378378
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
379379
// eslint-disable-next-line @typescript-eslint/no-deprecated
380380
const policy = getPolicy(iouReport?.policyID);

src/libs/TransactionUtils/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,10 @@ Onyx.connect({
137137
callback: (value) => (allTransactionViolations = value),
138138
});
139139

140-
let deprecatedCurrentUserEmail = '';
141140
let deprecatedCurrentUserAccountID = -1;
142141
Onyx.connect({
143142
key: ONYXKEYS.SESSION,
144143
callback: (val) => {
145-
deprecatedCurrentUserEmail = val?.email ?? '';
146144
deprecatedCurrentUserAccountID = val?.accountID ?? CONST.DEFAULT_NUMBER_ID;
147145
},
148146
});
@@ -897,7 +895,7 @@ function getAttendees(transaction: OnyxInputOrEntry<Transaction>): Attendee[] {
897895
const creatorAccountID = report?.ownerAccountID;
898896

899897
if (creatorAccountID) {
900-
const [creatorDetails] = getPersonalDetailsByIDs({accountIDs: [creatorAccountID], currentUserAccountID: deprecatedCurrentUserAccountID});
898+
const [creatorDetails] = getPersonalDetailsByIDs({accountIDs: [creatorAccountID]});
901899
const creatorEmail = creatorDetails?.login ?? '';
902900
const creatorDisplayName = creatorDetails?.displayName ?? creatorEmail;
903901

@@ -1455,7 +1453,7 @@ function isViolationDismissed(
14551453
const dismissedByEmails = Object.keys(violationDismissals);
14561454

14571455
// Current user dismissed it themselves
1458-
if (dismissedByEmails.includes(currentUserEmail || deprecatedCurrentUserEmail)) {
1456+
if (dismissedByEmails.includes(currentUserEmail)) {
14591457
return true;
14601458
}
14611459

@@ -2107,10 +2105,6 @@ function getAllSortedTransactions(iouReportID?: string): Array<OnyxEntry<Transac
21072105
});
21082106
}
21092107

2110-
function shouldShowRTERViolationMessage(transactions: Transaction[] | undefined, currentUserEmail: string, report: OnyxEntry<Report>, policy: OnyxEntry<Policy>) {
2111-
return transactions?.length === 1 && hasPendingUI(transactions?.at(0), getTransactionViolations(transactions?.at(0), allTransactionViolations, currentUserEmail, report, policy));
2112-
}
2113-
21142108
function isExpenseSplit(transaction: OnyxEntry<Transaction>, originalTransaction: OnyxEntry<Transaction>): boolean {
21152109
const {originalTransactionID, source, splits} = transaction?.comment ?? {};
21162110

@@ -2289,7 +2283,6 @@ export {
22892283
isPerDiemRequest,
22902284
isViolationDismissed,
22912285
isBrokenConnectionViolation,
2292-
shouldShowRTERViolationMessage,
22932286
isPartialTransaction,
22942287
isPendingCardOrScanningTransaction,
22952288
isScanning,

src/libs/actions/IOU.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ import {buildAddMembersToWorkspaceOnyxData, buildUpdateWorkspaceMembersRoleOnyxD
260260
import {buildOptimisticRecentlyUsedCurrencies, buildPolicyData, generatePolicyID} from './Policy/Policy';
261261
import {buildOptimisticPolicyRecentlyUsedTags, getPolicyTagsData} from './Policy/Tag';
262262
import type {GuidedSetupData} from './Report';
263-
import {buildInviteToRoomOnyxData, completeOnboarding, getCurrentUserAccountID, getCurrentUserEmail, notifyNewAction, optimisticReportLastData} from './Report';
263+
import {buildInviteToRoomOnyxData, completeOnboarding, getCurrentUserAccountID, notifyNewAction, optimisticReportLastData} from './Report';
264264
import {clearAllRelatedReportActionErrors} from './ReportActions';
265265
import {sanitizeRecentWaypoints} from './Transaction';
266266
import {removeDraftSplitTransaction, removeDraftTransaction, removeDraftTransactions} from './TransactionEdit';
@@ -8810,7 +8810,7 @@ function deleteMoneyRequest(
88108810
onyxMethod: Onyx.METHOD.MERGE,
88118811
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`,
88128812
value: {
8813-
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, updatedIOUReport),
8813+
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, updatedIOUReport, currentUserEmail),
88148814
},
88158815
});
88168816
}
@@ -8829,7 +8829,7 @@ function deleteMoneyRequest(
88298829
onyxMethod: Onyx.METHOD.MERGE,
88308830
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`,
88318831
value: {
8832-
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID),
8832+
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, currentUserEmail),
88338833
iouReportID: null,
88348834
...optimisticLastReportData,
88358835
},
@@ -9806,7 +9806,7 @@ function getPayMoneyRequestParams({
98069806
const optimisticChatReport = {
98079807
...chatReport,
98089808
lastReadTime: DateUtils.getDBTime(),
9809-
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID),
9809+
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, currentUserEmail),
98109810
iouReportID: null,
98119811
lastMessageText: getReportActionText(optimisticIOUReportAction),
98129812
lastMessageHtml: getReportActionHtml(optimisticIOUReportAction),
@@ -10223,13 +10223,13 @@ function canSubmitReport(
1022310223
transactions: OnyxTypes.Transaction[] | SearchTransaction[],
1022410224
allViolations: OnyxCollection<OnyxTypes.TransactionViolations> | undefined,
1022510225
isReportArchived: boolean,
10226+
currentUserEmailParam: string,
1022610227
) {
1022710228
const currentUserAccountID = getCurrentUserAccountID();
10228-
const currentUserEmailValue = getCurrentUserEmail() ?? '';
1022910229
const isOpenExpenseReport = isOpenExpenseReportReportUtils(report);
1023010230
const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
10231-
const hasAllPendingRTERViolations = allHavePendingRTERViolation(transactions, allViolations, currentUserEmail, report, policy);
10232-
const hasTransactionWithoutRTERViolation = hasAnyTransactionWithoutRTERViolation(transactions, allViolations, currentUserEmailValue, report, policy);
10231+
const hasAllPendingRTERViolations = allHavePendingRTERViolation(transactions, allViolations, currentUserEmailParam, report, policy);
10232+
const hasTransactionWithoutRTERViolation = hasAnyTransactionWithoutRTERViolation(transactions, allViolations, currentUserEmailParam, report, policy);
1023310233
const hasOnlyPendingCardOrScanFailTransactions = transactions.length > 0 && transactions.every((t) => isPendingCardOrScanningTransaction(t));
1023410234

1023510235
return (
@@ -10348,7 +10348,7 @@ function approveMoneyRequest(
1034810348
onyxMethod: Onyx.METHOD.MERGE,
1034910349
key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.chatReportID}`,
1035010350
value: {
10351-
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, updatedExpenseReport),
10351+
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, updatedExpenseReport, currentUserEmail),
1035210352
},
1035310353
};
1035410354
}

src/libs/actions/Report.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4822,7 +4822,7 @@ function clearDeleteTransactionNavigateBackUrl() {
48224822
}
48234823

48244824
/** Deletes a report and un-reports all transactions on the report along with its reportActions, any linked reports and any linked IOU report actions. */
4825-
function deleteAppReport(reportID: string | undefined) {
4825+
function deleteAppReport(reportID: string | undefined, currentUserEmailParam: string) {
48264826
if (!reportID) {
48274827
Log.warn('[Report] deleteReport called with no reportID');
48284828
return;
@@ -4842,7 +4842,7 @@ function deleteAppReport(reportID: string | undefined) {
48424842
const currentTime = DateUtils.getDBTime();
48434843
selfDMReport = buildOptimisticSelfDMReport(currentTime);
48444844
selfDMReportID = selfDMReport.reportID;
4845-
createdAction = buildOptimisticCreatedReportAction(currentUserEmail ?? '', currentTime);
4845+
createdAction = buildOptimisticCreatedReportAction(currentUserEmailParam ?? '', currentTime);
48464846
selfDMParameters = {reportID: selfDMReport.reportID, createdReportActionID: createdAction.reportActionID};
48474847
optimisticData.push(
48484848
{
@@ -5151,7 +5151,7 @@ function deleteAppReport(reportID: string | undefined) {
51515151
optimisticData.push({
51525152
onyxMethod: Onyx.METHOD.MERGE,
51535153
key: `${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`,
5154-
value: {hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, report?.reportID)},
5154+
value: {hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, report?.reportID, currentUserEmailParam)},
51555155
});
51565156
}
51575157

src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ConfirmModal from '@components/ConfirmModal';
1111
import PopoverWithMeasuredContent from '@components/PopoverWithMeasuredContent';
1212
import {useSearchContext} from '@components/Search/SearchContext';
1313
import useAncestors from '@hooks/useAncestors';
14+
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
1415
import useDeleteTransactions from '@hooks/useDeleteTransactions';
1516
import useDuplicateTransactionsAndViolations from '@hooks/useDuplicateTransactionsAndViolations';
1617
import useGetIOUReportFromReportAction from '@hooks/useGetIOUReportFromReportAction';
@@ -71,6 +72,7 @@ function PopoverReportActionContextMenu({ref}: PopoverReportActionContextMenuPro
7172
});
7273
const actionSheetAwareScrollViewContext = useContext(ActionSheetAwareScrollViewContext);
7374
const instanceIDRef = useRef('');
75+
const {email} = useCurrentUserPersonalDetails();
7476

7577
const [isPopoverVisible, setIsPopoverVisible] = useState(false);
7678
const [isDeleteCommentConfirmModalVisible, setIsDeleteCommentConfirmModalVisible] = useState(false);
@@ -363,7 +365,7 @@ function PopoverReportActionContextMenu({ref}: PopoverReportActionContextMenuPro
363365
deleteTransactions([originalMessage.IOUTransactionID], duplicateTransactions, duplicateTransactionViolations, currentSearchHash);
364366
}
365367
} else if (isReportPreviewAction(reportAction)) {
366-
deleteAppReport(reportAction.childReportID);
368+
deleteAppReport(reportAction.childReportID, email ?? '');
367369
} else if (reportAction) {
368370
// eslint-disable-next-line @typescript-eslint/no-deprecated
369371
InteractionManager.runAfterInteractions(() => {
@@ -384,6 +386,7 @@ function PopoverReportActionContextMenu({ref}: PopoverReportActionContextMenuPro
384386
deleteTransactions,
385387
currentSearchHash,
386388
isOriginalReportArchived,
389+
email,
387390
]);
388391

389392
const hideDeleteModal = () => {

0 commit comments

Comments
 (0)