Skip to content

Commit

Permalink
Merge branch 'main' into srikar-dontUseReportInArchived
Browse files Browse the repository at this point in the history
  • Loading branch information
srikarparsi authored Dec 27, 2024
2 parents dfa7dd7 + 1ba5d4d commit f257065
Show file tree
Hide file tree
Showing 35 changed files with 1,212 additions and 239 deletions.
2 changes: 1 addition & 1 deletion Mobile-Expensify
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1009007806
versionName "9.0.78-6"
versionCode 1009007901
versionName "9.0.79-1"
// Supported language variants must be declared here to avoid from being removed during the compilation.
// This also helps us to not include unnecessary language variants in the APK.
resConfigs "en", "es"
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>9.0.78</string>
<string>9.0.79</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -40,7 +40,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>9.0.78.6</string>
<string>9.0.79.1</string>
<key>FullStory</key>
<dict>
<key>OrgId</key>
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>9.0.78</string>
<string>9.0.79</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>9.0.78.6</string>
<string>9.0.79.1</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions ios/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleShortVersionString</key>
<string>9.0.78</string>
<string>9.0.79</string>
<key>CFBundleVersion</key>
<string>9.0.78.6</string>
<string>9.0.79.1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "9.0.78-6",
"version": "9.0.79-1",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
4 changes: 2 additions & 2 deletions src/components/ProductTrainingContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou
]);

const shouldShowProductTrainingTooltip = useMemo(() => {
return shouldRenderTooltip(tooltipName);
}, [shouldRenderTooltip, tooltipName]);
return shouldShow && shouldRenderTooltip(tooltipName);
}, [shouldRenderTooltip, tooltipName, shouldShow]);

const hideProductTrainingTooltip = useCallback(() => {
const tooltip = TOOLTIPS[tooltipName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ function MoneyRequestPreviewContent({
const route = useRoute<PlatformStackRouteProp<TransactionDuplicateNavigatorParamList, typeof SCREENS.TRANSACTION_DUPLICATE.REVIEW>>();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`);
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID || CONST.DEFAULT_NUMBER_ID}`);
const [session] = useOnyx(ONYXKEYS.SESSION);
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`);
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportID || CONST.DEFAULT_NUMBER_ID}`);

const policy = PolicyUtils.getPolicy(iouReport?.policyID);
const isMoneyRequestAction = ReportActionsUtils.isMoneyRequestAction(action);
Expand Down
27 changes: 12 additions & 15 deletions src/libs/CardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ function getEligibleBankAccountsForCard(bankAccountsList: OnyxEntry<BankAccountL
function sortCardsByCardholderName(cardsList: OnyxEntry<WorkspaceCardsList>, personalDetails: OnyxEntry<PersonalDetailsList>): Card[] {
const {cardList, ...cards} = cardsList ?? {};
return Object.values(cards).sort((cardA: Card, cardB: Card) => {
const userA = personalDetails?.[cardA.accountID ?? '-1'] ?? {};
const userB = personalDetails?.[cardB.accountID ?? '-1'] ?? {};
const userA = cardA.accountID ? personalDetails?.[cardA.accountID] ?? {} : {};
const userB = cardB.accountID ? personalDetails?.[cardB.accountID] ?? {} : {};

const aName = PersonalDetailsUtils.getDisplayNameOrDefault(userA);
const bName = PersonalDetailsUtils.getDisplayNameOrDefault(userB);
Expand Down Expand Up @@ -251,17 +251,15 @@ function isCustomFeed(feed: CompanyCardFeed): boolean {
return [CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD, CONST.COMPANY_CARD.FEED_BANK_NAME.VISA, CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX].some((value) => value === feed);
}

function getCompanyFeeds(cardFeeds: OnyxEntry<CardFeeds>): CompanyFeeds {
return {...cardFeeds?.settings?.companyCards, ...cardFeeds?.settings?.oAuthAccountDetails};
}

function removeExpensifyCardFromCompanyCards(cardFeeds: OnyxEntry<CardFeeds>): CompanyFeeds {
if (!cardFeeds) {
return {};
}

const companyCards = getCompanyFeeds(cardFeeds);
return Object.fromEntries(Object.entries(companyCards).filter(([key]) => key !== CONST.EXPENSIFY_CARD.BANK));
function getCompanyFeeds(cardFeeds: OnyxEntry<CardFeeds>, shouldFilterOutRemovedFeeds = false): CompanyFeeds {
return Object.fromEntries(
Object.entries(cardFeeds?.settings?.companyCards ?? {}).filter(([key, value]) => {
if (shouldFilterOutRemovedFeeds && value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
return false;
}
return key !== CONST.EXPENSIFY_CARD.BANK;
}),
);
}

function getCardFeedName(feedType: CompanyCardFeed): string {
Expand Down Expand Up @@ -348,7 +346,7 @@ const getCorrectStepForSelectedBank = (selectedBank: ValueOf<typeof CONST.COMPAN
};

function getSelectedFeed(lastSelectedFeed: OnyxEntry<CompanyCardFeed>, cardFeeds: OnyxEntry<CardFeeds>): CompanyCardFeed | undefined {
const defaultFeed = Object.keys(removeExpensifyCardFromCompanyCards(cardFeeds)).at(0) as CompanyCardFeed | undefined;
const defaultFeed = Object.keys(getCompanyFeeds(cardFeeds, true)).at(0) as CompanyCardFeed | undefined;
return lastSelectedFeed ?? defaultFeed;
}

Expand Down Expand Up @@ -410,7 +408,6 @@ export {
getSelectedFeed,
getCorrectStepForSelectedBank,
getCustomOrFormattedFeedName,
removeExpensifyCardFromCompanyCards,
getFilteredCardList,
hasOnlyOneCardToAssign,
checkIfNewFeedConnected,
Expand Down
3 changes: 3 additions & 0 deletions src/libs/DebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa
case 'iouReportID':
case 'preexistingReportID':
case 'private_isArchived':
case 'welcomeMessage':
return validateString(value);
case 'hasOutstandingChildRequest':
case 'hasOutstandingChildTask':
Expand Down Expand Up @@ -513,6 +514,7 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION,
pendingFields: 'object',
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE,
permissions: 'array',
},
'number',
);
Expand Down Expand Up @@ -621,6 +623,7 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa
partial: CONST.RED_BRICK_ROAD_PENDING_ACTION,
reimbursed: CONST.RED_BRICK_ROAD_PENDING_ACTION,
preview: CONST.RED_BRICK_ROAD_PENDING_ACTION,
welcomeMessage: CONST.RED_BRICK_ROAD_PENDING_ACTION,
});
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/libs/Network/SequentialQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ function process(): Promise<void> {
return currentRequestPromise;
}

/**
* @param shouldResetPromise Determines whether the isReadyPromise should be reset.
* A READ request will wait until all the WRITE requests are done, using the isReadyPromise promise.
* Resetting can cause unresolved READ requests to hang if tied to the old promise,
* so some cases (e.g., unpausing) require skipping the reset to maintain proper behavior.
*/
function flush(shouldResetPromise = true) {
// When the queue is paused, return early. This will keep an requests in the queue and they will get flushed again when the queue is unpaused
if (isQueuePaused) {
Expand Down Expand Up @@ -198,6 +204,11 @@ function unpause() {
const numberOfPersistedRequests = PersistedRequests.getAll().length || 0;
Log.info(`[SequentialQueue] Unpausing the queue and flushing ${numberOfPersistedRequests} requests`);
isQueuePaused = false;

// When the queue is paused and then unpaused, we call flush which by defaults recreates the isReadyPromise.
// After all the WRITE requests are done, the isReadyPromise is resolved, but since it's a new instance of promise,
// the pending READ request never received the resolved callback. That's why we don't want to recreate
// the promise when unpausing the queue.
flush(false);
}

Expand Down
5 changes: 3 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import type {ErrorFields, Errors, Icon, PendingAction} from '@src/types/onyx/Ony
import type {OriginalMessageChangeLog, PaymentMethodType} from '@src/types/onyx/OriginalMessage';
import type {Status} from '@src/types/onyx/PersonalDetails';
import type {ConnectionName} from '@src/types/onyx/Policy';
import type {NotificationPreference, Participants, Participant as ReportParticipant} from '@src/types/onyx/Report';
import type {InvoiceReceiverType, NotificationPreference, Participants, Participant as ReportParticipant} from '@src/types/onyx/Report';
import type {Message, OldDotReportAction, ReportActions} from '@src/types/onyx/ReportAction';
import type {PendingChatMember} from '@src/types/onyx/ReportMetadata';
import type {SearchPolicy, SearchReport, SearchTransaction} from '@src/types/onyx/SearchResults';
Expand Down Expand Up @@ -6771,14 +6771,15 @@ function getChatByParticipants(newParticipantList: number[], reports: OnyxCollec
/**
* Attempts to find an invoice chat report in onyx with the provided policyID and receiverID.
*/
function getInvoiceChatByParticipants(policyID: string, receiverID: string | number, reports: OnyxCollection<Report> = allReports): OnyxEntry<Report> {
function getInvoiceChatByParticipants(receiverID: string | number, receiverType: InvoiceReceiverType, policyID?: string, reports: OnyxCollection<Report> = allReports): OnyxEntry<Report> {
return Object.values(reports ?? {}).find((report) => {
if (!report || !isInvoiceRoom(report) || isArchivedRoomWithID(report?.reportID)) {
return false;
}

const isSameReceiver =
report.invoiceReceiver &&
report.invoiceReceiver.type === receiverType &&
(('accountID' in report.invoiceReceiver && report.invoiceReceiver.accountID === receiverID) ||
('policyID' in report.invoiceReceiver && report.invoiceReceiver.policyID === receiverID));

Expand Down
10 changes: 8 additions & 2 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,11 @@ function getUpdatedTransaction({

if (Object.hasOwn(transactionChanges, 'category') && typeof transactionChanges.category === 'string') {
updatedTransaction.category = transactionChanges.category;
const {categoryTaxCode, categoryTaxAmount} = getCategoryTaxCodeAndAmount(transactionChanges.category, transaction, policy);
if (categoryTaxCode && categoryTaxAmount !== undefined) {
updatedTransaction.taxCode = categoryTaxCode;
updatedTransaction.taxAmount = categoryTaxAmount;
}
}

if (Object.hasOwn(transactionChanges, 'tag') && typeof transactionChanges.tag === 'string') {
Expand Down Expand Up @@ -1258,11 +1263,12 @@ function buildTransactionsMergeParams(reviewDuplicates: OnyxEntry<ReviewDuplicat

function getCategoryTaxCodeAndAmount(category: string, transaction: OnyxEntry<Transaction>, policy: OnyxEntry<Policy>) {
const taxRules = policy?.rules?.expenseRules?.filter((rule) => rule.tax);
if (!taxRules || taxRules?.length === 0) {
if (!taxRules || taxRules?.length === 0 || isDistanceRequest(transaction)) {
return {categoryTaxCode: undefined, categoryTaxAmount: undefined};
}

const categoryTaxCode = getCategoryDefaultTaxRate(taxRules, category, policy?.taxRates?.defaultExternalID);
const defaultTaxCode = getDefaultTaxCode(policy, transaction, getCurrency(transaction));
const categoryTaxCode = getCategoryDefaultTaxRate(taxRules, category, defaultTaxCode);
const categoryTaxPercentage = getTaxValue(policy, transaction, categoryTaxCode ?? '');
let categoryTaxAmount;

Expand Down
Loading

0 comments on commit f257065

Please sign in to comment.