Skip to content

Commit

Permalink
Merge branch 'Expensify:main' into missing-details-flow-part2
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1206agra authored Oct 2, 2024
2 parents 992745d + 9627f5f commit 7042d0a
Show file tree
Hide file tree
Showing 21 changed files with 148 additions and 76 deletions.
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 1009004300
versionName "9.0.43-0"
versionCode 1009004301
versionName "9.0.43-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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>9.0.43.0</string>
<string>9.0.43.1</string>
<key>FullStory</key>
<dict>
<key>OrgId</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>9.0.43.0</string>
<string>9.0.43.1</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ios/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleShortVersionString</key>
<string>9.0.43</string>
<key>CFBundleVersion</key>
<string>9.0.43.0</string>
<string>9.0.43.1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "9.0.43-0",
"version": "9.0.43-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 Expand Up @@ -132,7 +132,7 @@
"react-map-gl": "^7.1.3",
"react-native": "0.75.2",
"react-native-android-location-enabler": "^2.0.1",
"react-native-app-logs": "git+https://github.com/margelo/react-native-app-logs#1c183909ca2275b1fb0b2575f14ff22a36f2ff48",
"react-native-app-logs": "git+https://github.com/margelo/react-native-app-logs#4653bc25b600497c5c64f2897f9778c796193238",
"react-native-blob-util": "0.19.4",
"react-native-collapsible": "^1.6.2",
"react-native-config": "1.5.0",
Expand All @@ -151,7 +151,7 @@
"react-native-launch-arguments": "^4.0.2",
"react-native-localize": "^2.2.6",
"react-native-modal": "^13.0.0",
"react-native-onyx": "2.0.68",
"react-native-onyx": "2.0.71",
"react-native-pager-view": "6.4.1",
"react-native-pdf": "6.7.3",
"react-native-performance": "^5.1.0",
Expand Down
8 changes: 6 additions & 2 deletions src/components/ReportActionItem/MoneyReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as reportActions from '@src/libs/actions/Report';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Policy, PolicyReportField, Report} from '@src/types/onyx';
import type {PendingAction} from '@src/types/onyx/OnyxCommon';

type MoneyReportViewProps = {
/** The report currently being looked at */
Expand All @@ -41,9 +42,11 @@ type MoneyReportViewProps = {

/** Flag to show, hide the thread divider line */
shouldHideThreadDividerLine: boolean;

pendingAction?: PendingAction;
};

function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTotal = true, shouldHideThreadDividerLine}: MoneyReportViewProps) {
function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTotal = true, shouldHideThreadDividerLine, pendingAction}: MoneyReportViewProps) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand Down Expand Up @@ -118,7 +121,8 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo

return (
<OfflineWithFeedback
pendingAction={report.pendingFields?.[fieldKey]}
// Need to return undefined when we have pendingAction to avoid the duplicate pending action
pendingAction={pendingAction ? undefined : report.pendingFields?.[fieldKey]}
errors={report.errorFields?.[fieldKey]}
errorRowStyles={styles.ph5}
key={`menuItem-${fieldKey}`}
Expand Down
45 changes: 25 additions & 20 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
receiptURIs = ReceiptUtils.getThumbnailAndImageURIs(updatedTransaction ?? transaction);
}
const pendingAction = transaction?.pendingAction;
const getPendingFieldAction = (fieldPath: TransactionPendingFieldsKey) => transaction?.pendingFields?.[fieldPath] ?? pendingAction;
// Need to return undefined when we have pendingAction to avoid the duplicate pending action
const getPendingFieldAction = (fieldPath: TransactionPendingFieldsKey) => (pendingAction ? undefined : transaction?.pendingFields?.[fieldPath]);

const getErrorForField = useCallback(
(field: ViolationField, data?: OnyxTypes.TransactionViolation['data'], policyHasDependentTags = false, tagValue?: string) => {
Expand Down Expand Up @@ -476,10 +477,12 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
{shouldShowAnimatedBackground && <AnimatedEmptyStateBackground />}
<>
{shouldShowReceiptAudit && (
<ReceiptAudit
notes={receiptViolations}
shouldShowAuditResult={!!shouldShowAuditMessage}
/>
<OfflineWithFeedback pendingAction={getPendingFieldAction('receipt')}>
<ReceiptAudit
notes={receiptViolations}
shouldShowAuditResult={!!shouldShowAuditMessage}
/>
</OfflineWithFeedback>
)}
{(hasReceipt || errors) && (
<OfflineWithFeedback
Expand Down Expand Up @@ -529,21 +532,23 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
</OfflineWithFeedback>
)}
{shouldShowReceiptEmptyState && (
<ReceiptEmptyState
hasError={hasErrors}
disabled={!canEditReceipt}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.EDIT,
iouType,
transaction?.transactionID ?? '-1',
report?.reportID ?? '-1',
Navigation.getReportRHPActiveRoute(),
),
)
}
/>
<OfflineWithFeedback pendingAction={getPendingFieldAction('receipt')}>
<ReceiptEmptyState
hasError={hasErrors}
disabled={!canEditReceipt}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.EDIT,
iouType,
transaction?.transactionID ?? '-1',
report?.reportID ?? '-1',
Navigation.getReportRHPActiveRoute(),
),
)
}
/>
</OfflineWithFeedback>
)}
{!shouldShowReceiptEmptyState && !hasReceipt && <View style={{marginVertical: 6}} />}
{shouldShowAuditMessage && <ReceiptAuditMessages notes={receiptImageViolations} />}
Expand Down
3 changes: 2 additions & 1 deletion src/libs/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ function waitForWrites<TCommand extends ReadCommand>(command: TCommand) {
function read<TCommand extends ReadCommand>(command: TCommand, apiCommandParameters: ApiRequestCommandParameters[TCommand], onyxData: OnyxData = {}): void {
Log.info('[API] Called API.read', false, {command, ...apiCommandParameters});

// Apply optimistic updates of read requests immediately
const request = prepareRequest(command, CONST.API_REQUEST_TYPE.READ, apiCommandParameters, onyxData);
waitForWrites(command).then(() => {
const request = prepareRequest(command, CONST.API_REQUEST_TYPE.READ, apiCommandParameters, onyxData);
processRequest(request, CONST.API_REQUEST_TYPE.READ);
});
}
Expand Down
12 changes: 9 additions & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3755,11 +3755,12 @@ function getReportName(
parentReportActionParam?: OnyxInputOrEntry<ReportAction>,
personalDetails?: Partial<PersonalDetailsList>,
invoiceReceiverPolicy?: OnyxEntry<Policy>,
shouldIncludePolicyName = false,
): string {
const reportID = report?.reportID;
const cacheKey = getCacheKey(report);

if (reportID) {
if (reportID && !isUserCreatedPolicyRoom(report) && !isDefaultRoom(report)) {
const reportNameFromCache = reportNameCache.get(cacheKey);

if (reportNameFromCache?.reportName && reportNameFromCache.reportName === report?.reportName) {
Expand Down Expand Up @@ -3873,6 +3874,11 @@ function getReportName(
formattedName = getInvoicesChatName(report, invoiceReceiverPolicy);
}

if (shouldIncludePolicyName && (isUserCreatedPolicyRoom(report) || isDefaultRoom(report))) {
const policyName = getPolicyName(report, true);
formattedName = policyName ? `${policyName}${report?.reportName}` : report?.reportName;
}

if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) {
formattedName += ` (${Localize.translateLocal('common.archived')})`;
}
Expand Down Expand Up @@ -3929,8 +3935,8 @@ function getPayeeName(report: OnyxEntry<Report>): string | undefined {
/**
* Get either the policyName or domainName the chat is tied to
*/
function getChatRoomSubtitle(report: OnyxEntry<Report>): string | undefined {
if (isChatThread(report)) {
function getChatRoomSubtitle(report: OnyxEntry<Report>, isTitleIncludePolicyName = false): string | undefined {
if (isChatThread(report) || ((isUserCreatedPolicyRoom(report) || isDefaultRoom(report)) && isTitleIncludePolicyName)) {
return '';
}
if (isSelfDM(report)) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ function getOptionData({
result.phoneNumber = personalDetail?.phoneNumber ?? '';
}

const reportName = ReportUtils.getReportName(report, policy, undefined, undefined, invoiceReceiverPolicy);
const reportName = ReportUtils.getReportName(report, policy, undefined, undefined, invoiceReceiverPolicy, true);

result.text = reportName;
result.subtitle = subtitle;
Expand Down
44 changes: 41 additions & 3 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7621,24 +7621,43 @@ function detachReceipt(transactionID: string) {
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: newTransaction,
value: {
...newTransaction,
pendingFields: {
receipt: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
},
},
},
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
pendingFields: {
receipt: null,
},
},
},
];
const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
...(transaction ?? null),
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('iou.error.receiptDeleteFailureError'),
pendingFields: {
receipt: null,
},
},
},
];

const parameters: DetachReceiptParams = {transactionID};

API.write(WRITE_COMMANDS.DETACH_RECEIPT, parameters, {optimisticData, failureData});
API.write(WRITE_COMMANDS.DETACH_RECEIPT, parameters, {optimisticData, successData, failureData});
}

function replaceReceipt(transactionID: string, file: File, source: string) {
Expand All @@ -7656,9 +7675,25 @@ function replaceReceipt(transactionID: string, file: File, source: string) {
value: {
receipt: receiptOptimistic,
filename: file.name,
pendingFields: {
receipt: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
pendingFields: {
receipt: null,
},
},
},
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -7667,6 +7702,9 @@ function replaceReceipt(transactionID: string, file: File, source: string) {
receipt: !isEmptyObject(oldReceipt) ? oldReceipt : null,
filename: transaction?.filename,
errors: getReceiptError(receiptOptimistic, file.name),
pendingFields: {
receipt: null,
},
},
},
];
Expand All @@ -7676,7 +7714,7 @@ function replaceReceipt(transactionID: string, file: File, source: string) {
receipt: file,
};

API.write(WRITE_COMMANDS.REPLACE_RECEIPT, parameters, {optimisticData, failureData});
API.write(WRITE_COMMANDS.REPLACE_RECEIPT, parameters, {optimisticData, successData, failureData});
}

/**
Expand Down
14 changes: 11 additions & 3 deletions src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto
const isTaskReport = ReportUtils.isTaskReport(report);
const reportHeaderData = !isTaskReport && !isChatThread && report?.parentReportID ? parentReport : report;
// Use sorted display names for the title for group chats on native small screen widths
const title = ReportUtils.getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy);
const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData);
const title = ReportUtils.getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy, true);
const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData, true);
const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(reportHeaderData);
const reportDescription = ReportUtils.getReportDescriptionText(report);
const policyName = ReportUtils.getPolicyName(report, true);
Expand Down Expand Up @@ -120,7 +120,15 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto
);

const renderAdditionalText = () => {
if (shouldShowSubtitle() || isPersonalExpenseChat || !policyName || !isEmptyObject(parentNavigationSubtitleData) || isSelfDM) {
if (
shouldShowSubtitle() ||
isPersonalExpenseChat ||
!policyName ||
!isEmptyObject(parentNavigationSubtitleData) ||
isSelfDM ||
ReportUtils.isUserCreatedPolicyRoom(report) ||
ReportUtils.isDefaultRoom(report)
) {
return null;
}
return (
Expand Down
Loading

0 comments on commit 7042d0a

Please sign in to comment.