From 219591007c692cdcf48395ae21ce1472bcb42e1c Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 26 Jul 2023 12:17:58 +0100 Subject: [PATCH 01/36] Use the PolicyUtils is policy admin method --- src/libs/actions/Policy.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 4aad99832762..e327b6fe772d 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -160,16 +160,6 @@ function isAdminOfFreePolicy(policies) { return _.some(policies, (policy) => policy && policy.type === CONST.POLICY.TYPE.FREE && policy.role === CONST.POLICY.ROLE.ADMIN); } -/** - * Is the user the owner of the given policy? - * - * @param {Object} policy - * @returns {Boolean} - */ -function isPolicyOwner(policy) { - return _.keys(loginList).includes(policy.owner); -} - /** * Check if the user has any active free policies (aka workspaces) * @@ -1130,5 +1120,4 @@ export { openWorkspaceInvitePage, removeWorkspace, setWorkspaceInviteMembersDraft, - isPolicyOwner, }; From 25b83ac8fd6932d0fc8e68a9dd6baae629a85a88 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 26 Jul 2023 12:22:21 +0100 Subject: [PATCH 02/36] Add PolicyUtils import --- src/pages/ReimbursementAccount/ReimbursementAccountPage.js | 4 ++-- src/pages/workspace/WorkspaceInitialPage.js | 2 +- src/pages/workspace/WorkspaceInviteMessagePage.js | 3 ++- src/pages/workspace/WorkspaceInvitePage.js | 2 +- src/pages/workspace/WorkspaceMembersPage.js | 2 +- src/pages/workspace/WorkspacePageWithSections.js | 3 +-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index a07018ece1a9..2706f667a374 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -32,7 +32,7 @@ import * as ReimbursementAccountProps from './reimbursementAccountPropTypes'; import reimbursementAccountDraftPropTypes from './ReimbursementAccountDraftPropTypes'; import withPolicy from '../workspace/withPolicy'; import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView'; -import * as Policy from '../../libs/actions/Policy'; +import * as PolicyUtils from '../../libs/PolicyUtils'; const propTypes = { /** Plaid SDK token to use to initialize the widget */ @@ -332,7 +332,7 @@ class ReimbursementAccountPage extends React.Component { const policyName = lodashGet(this.props.policy, 'name'); const policyID = lodashGet(this.props.route.params, 'policyID'); - if (_.isEmpty(this.props.policy) || !Policy.isPolicyOwner(this.props.policy)) { + if (_.isEmpty(this.props.policy) || !PolicyUtils.isPolicyAdmin(this.props.policy)) { return ( ( Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - shouldShow={_.isEmpty(props.policy) || !Policy.isPolicyOwner(props.policy)} + shouldShow={_.isEmpty(props.policy) || !PolicyUtils.isPolicyAdmin(props.policy)} subtitleKey={_.isEmpty(props.policy) ? undefined : 'workspace.common.notAuthorized'} > Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} > diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index b397009cafa3..4208f32e2172 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -272,7 +272,7 @@ class WorkspaceInvitePage extends React.Component { const sections = didScreenTransitionEnd ? this.getSections() : []; return ( Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} > diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 2563a469f1d7..ea56c632a49b 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -405,7 +405,7 @@ function WorkspaceMembersPage(props) { > {({safeAreaPaddingBottomStyle}) => ( Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} > diff --git a/src/pages/workspace/WorkspacePageWithSections.js b/src/pages/workspace/WorkspacePageWithSections.js index 31ed7eeb93a5..3a1b95798c42 100644 --- a/src/pages/workspace/WorkspacePageWithSections.js +++ b/src/pages/workspace/WorkspacePageWithSections.js @@ -6,7 +6,6 @@ import lodashGet from 'lodash/get'; import _ from 'underscore'; import styles from '../../styles/styles'; import Navigation from '../../libs/Navigation/Navigation'; -import * as Policy from '../../libs/actions/Policy'; import compose from '../../libs/compose'; import ROUTES from '../../ROUTES'; import HeaderWithBackButton from '../../components/HeaderWithBackButton'; @@ -105,7 +104,7 @@ function WorkspacePageWithSections({backButtonRoute, children, footer, guidesCal > Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - shouldShow={_.isEmpty(policy) || !Policy.isPolicyOwner(policy)} + shouldShow={_.isEmpty(policy) || !PolicyUtils.isPolicyAdmin(policy)} subtitleKey={_.isEmpty(policy) ? undefined : 'workspace.common.notAuthorized'} > Date: Wed, 26 Jul 2023 12:47:57 +0100 Subject: [PATCH 03/36] One more policyutils import --- src/pages/workspace/WorkspacePageWithSections.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/WorkspacePageWithSections.js b/src/pages/workspace/WorkspacePageWithSections.js index 3a1b95798c42..398f650729d1 100644 --- a/src/pages/workspace/WorkspacePageWithSections.js +++ b/src/pages/workspace/WorkspacePageWithSections.js @@ -5,6 +5,7 @@ import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; import _ from 'underscore'; import styles from '../../styles/styles'; +import * as PolicyUtils from '../../libs/PolicyUtils'; import Navigation from '../../libs/Navigation/Navigation'; import compose from '../../libs/compose'; import ROUTES from '../../ROUTES'; From 21ef3fa7936279ea13c12bda3a1c5f7264609d4f Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 26 Jul 2023 13:03:41 +0100 Subject: [PATCH 04/36] Remove unused variable --- src/libs/actions/Policy.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 2791b44198a6..81bb39f15333 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -65,12 +65,6 @@ Onyx.connect({ callback: (val) => (allPersonalDetails = val), }); -let loginList; -Onyx.connect({ - key: ONYXKEYS.LOGIN_LIST, - callback: (val) => (loginList = val), -}); - /** * Stores in Onyx the policy ID of the last workspace that was accessed by the user * @param {String|null} policyID From b5a6d3584bfdd851d10a2b42d3321abaa65ffcc9 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Tue, 1 Aug 2023 22:25:30 +0100 Subject: [PATCH 05/36] Display NVP-enabled control policies in NewDot --- src/libs/PolicyUtils.js | 11 +++++++++-- .../SidebarScreen/FloatingActionButtonAndPopover.js | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 582271d6610e..0de7f5137e8b 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -10,7 +10,14 @@ import ONYXKEYS from '../ONYXKEYS'; * @returns {Array} */ function getActivePolicies(policies) { - return _.filter(policies, (policy) => policy && policy.type === CONST.POLICY.TYPE.FREE && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); + return _.filter(policies, (policy) => { + console.log(policy); + return ( + policy && + (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isControlWorkspaceEnabled)) && + policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE + ); + }); } /** @@ -86,7 +93,7 @@ function getPolicyBrickRoadIndicatorStatus(policy, policyMembersCollection) { function shouldShowPolicy(policy, isOffline) { return ( policy && - policy.type === CONST.POLICY.TYPE.FREE && + (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isControlWorkspaceEnabled)) && policy.role === CONST.POLICY.ROLE.ADMIN && (isOffline || policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !_.isEmpty(policy.errors)) ); diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 1ccdf9261b19..a4b313c569ba 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -36,6 +36,7 @@ const policySelector = (policy) => policy && { type: policy.type, role: policy.role, + isControlWorkspaceEnabled: policy.isControlWorkspaceEnabled, pendingAction: policy.pendingAction, }; @@ -174,6 +175,7 @@ function FloatingActionButtonAndPopover(props) { })); const workspaces = PolicyUtils.getActivePolicies(props.allPolicies); + console.log('w', workspaces); return ( From 6602a92261982c970397f5c0c761552f4d51c703 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 4 Aug 2023 18:48:47 +0100 Subject: [PATCH 06/36] Update policy flag name --- src/libs/PolicyUtils.js | 4 ++-- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 0de7f5137e8b..9d2c28a58573 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -14,7 +14,7 @@ function getActivePolicies(policies) { console.log(policy); return ( policy && - (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isControlWorkspaceEnabled)) && + (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ); }); @@ -93,7 +93,7 @@ function getPolicyBrickRoadIndicatorStatus(policy, policyMembersCollection) { function shouldShowPolicy(policy, isOffline) { return ( policy && - (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isControlWorkspaceEnabled)) && + (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && policy.role === CONST.POLICY.ROLE.ADMIN && (isOffline || policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !_.isEmpty(policy.errors)) ); diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index a4b313c569ba..6ddbf8d0822f 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -36,7 +36,7 @@ const policySelector = (policy) => policy && { type: policy.type, role: policy.role, - isControlWorkspaceEnabled: policy.isControlWorkspaceEnabled, + isPolicyExpenseChatEnabled: policy.isPolicyExpenseChatEnabled, pendingAction: policy.pendingAction, }; From fbc70a0bac00f6a438e056425989760ffece2ff0 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 4 Aug 2023 19:43:53 +0100 Subject: [PATCH 07/36] clean up --- src/libs/PolicyUtils.js | 11 +++++------ .../SidebarScreen/FloatingActionButtonAndPopover.js | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 9d2c28a58573..89cc183f496c 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -10,14 +10,13 @@ import ONYXKEYS from '../ONYXKEYS'; * @returns {Array} */ function getActivePolicies(policies) { - return _.filter(policies, (policy) => { - console.log(policy); - return ( + return _.filter( + policies, + (policy) => policy && (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && - policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE - ); - }); + policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, + ); } /** diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 6ddbf8d0822f..dc73ba956838 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -175,7 +175,6 @@ function FloatingActionButtonAndPopover(props) { })); const workspaces = PolicyUtils.getActivePolicies(props.allPolicies); - console.log('w', workspaces); return ( From 286f8c26e22afb96baf516af040b38834a9a3f7b Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Tue, 8 Aug 2023 21:28:57 +0100 Subject: [PATCH 08/36] Use isPolicyExpenseChatEnabled --- src/libs/PolicyUtils.js | 10 ++-------- src/libs/actions/Policy.js | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 89cc183f496c..164f284a4ef5 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -10,13 +10,7 @@ import ONYXKEYS from '../ONYXKEYS'; * @returns {Array} */ function getActivePolicies(policies) { - return _.filter( - policies, - (policy) => - policy && - (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && - policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, - ); + return _.filter(policies, (policy) => policy && policy.isPolicyExpenseChatEnabled && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); } /** @@ -92,7 +86,7 @@ function getPolicyBrickRoadIndicatorStatus(policy, policyMembersCollection) { function shouldShowPolicy(policy, isOffline) { return ( policy && - (policy.type === CONST.POLICY.TYPE.FREE || (policy.type === CONST.POLICY.TYPE.CORPORATE && policy.isPolicyExpenseChatEnabled)) && + policy.isPolicyExpenseChatEnabled && policy.role === CONST.POLICY.ROLE.ADMIN && (isOffline || policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !_.isEmpty(policy.errors)) ); diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 4a58f52eff0a..93621a517ee3 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -906,6 +906,7 @@ function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName name: workspaceName, role: CONST.POLICY.ROLE.ADMIN, owner: sessionEmail, + isPolicyExpenseChatEnabled: true, outputCurrency: lodashGet(allPersonalDetails, [sessionAccountID, 'localCurrencyCode'], CONST.CURRENCY.USD), pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, }, From 6da86d579f67f1f5338befe07bf45dcee5e190b3 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Fri, 11 Aug 2023 11:15:09 -0700 Subject: [PATCH 09/36] Ignore hasOutstandingIOU from child iouReport --- src/libs/OptionsListUtils.js | 2 +- src/libs/ReportUtils.js | 21 +++++---------------- src/libs/SidebarUtils.js | 4 ++-- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index b574bfd3d00e..33f693ef1de3 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -638,7 +638,7 @@ function getOptions( const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number.e164 : searchInputValue.toLowerCase(); // Filter out all the reports that shouldn't be displayed - const filteredReports = _.filter(reports, (report) => ReportUtils.shouldReportBeInOptionList(report, Navigation.getTopmostReportId(), false, null, betas, policies)); + const filteredReports = _.filter(reports, (report) => ReportUtils.shouldReportBeInOptionList(report, Navigation.getTopmostReportId(), false, betas, policies)); // Sorting the reports works like this: // - Order everything by the last message timestamp (descending) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index e8ef18a3ca27..6ffcc44c19ee 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1134,12 +1134,10 @@ function getMoneyRequestAction(reportAction = {}) { * Determines if a report has an IOU that is waiting for an action from the current user (either Pay or Add a credit bank account) * * @param {Object} report (chatReport or iouReport) - * @param {Object} allReportsDict * @returns {boolean} */ -function isWaitingForIOUActionFromCurrentUser(report, allReportsDict = null) { - const allAvailableReports = allReportsDict || allReports; - if (!report || !allAvailableReports) { +function isWaitingForIOUActionFromCurrentUser(report) { + if (!report) { return false; } @@ -1148,15 +1146,7 @@ function isWaitingForIOUActionFromCurrentUser(report, allReportsDict = null) { return true; } - let reportToLook = report; - if (report.iouReportID) { - const iouReport = allAvailableReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`]; - if (iouReport) { - reportToLook = iouReport; - } - } - // Money request waiting for current user to Pay (from chat or from iou report) - if (reportToLook.ownerAccountID && (reportToLook.ownerAccountID !== currentUserAccountID || currentUserAccountID === reportToLook.managerID) && reportToLook.hasOutstandingIOU) { + if (report.hasOutstandingIOU && report.ownerAccountID && (report.ownerAccountID !== currentUserAccountID || currentUserAccountID === report.managerID)) { return true; } @@ -2337,13 +2327,12 @@ function canAccessReport(report, policies, betas, allReportActions) { * @param {Object} report * @param {String} currentReportId * @param {Boolean} isInGSDMode - * @param {Object} iouReports * @param {String[]} betas * @param {Object} policies * @param {Object} allReportActions * @returns {boolean} */ -function shouldReportBeInOptionList(report, currentReportId, isInGSDMode, iouReports, betas, policies, allReportActions) { +function shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas, policies, allReportActions) { const isInDefaultMode = !isInGSDMode; // Exclude reports that have no data because there wouldn't be anything to show in the option item. @@ -2369,7 +2358,7 @@ function shouldReportBeInOptionList(report, currentReportId, isInGSDMode, iouRep } // Include reports that are relevant to the user in any view mode. Criteria include having a draft, having an outstanding IOU, or being assigned to an open task. - if (report.hasDraft || isWaitingForIOUActionFromCurrentUser(report, iouReports) || isWaitingForTaskCompleteFromAssignee(report)) { + if (report.hasDraft || isWaitingForIOUActionFromCurrentUser(report) || isWaitingForTaskCompleteFromAssignee(report)) { return true; } diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index 561d91a63a1f..d97ad15f86c7 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -87,7 +87,7 @@ function getOrderedReportIDs(currentReportId, allReportsDict, betas, policies, p // Filter out all the reports that shouldn't be displayed const reportsToDisplay = _.filter(allReportsDict, (report) => - ReportUtils.shouldReportBeInOptionList(report, currentReportId, isInGSDMode, allReportsDict, betas, policies, allReportActions), + ReportUtils.shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas, policies, allReportActions), ); if (_.isEmpty(reportsToDisplay)) { @@ -131,7 +131,7 @@ function getOrderedReportIDs(currentReportId, allReportsDict, betas, policies, p return; } - if (ReportUtils.isWaitingForIOUActionFromCurrentUser(report, allReportsDict)) { + if (ReportUtils.isWaitingForIOUActionFromCurrentUser(report)) { outstandingIOUReports.push(report); return; } From c2abbe3fd3668fe4e895a0c5a2ddf8f3628962bc Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Fri, 11 Aug 2023 12:06:22 -0700 Subject: [PATCH 10/36] Fix isWaitingForIOUActionFromCurrentUser tests --- src/libs/SidebarUtils.js | 4 +- tests/unit/ReportUtilsTest.js | 82 ++++++++--------------------------- 2 files changed, 20 insertions(+), 66 deletions(-) diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index d97ad15f86c7..5a7d7f02a216 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -86,9 +86,7 @@ function getOrderedReportIDs(currentReportId, allReportsDict, betas, policies, p const isInDefaultMode = !isInGSDMode; // Filter out all the reports that shouldn't be displayed - const reportsToDisplay = _.filter(allReportsDict, (report) => - ReportUtils.shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas, policies, allReportActions), - ); + const reportsToDisplay = _.filter(allReportsDict, (report) => ReportUtils.shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas, policies, allReportActions)); if (_.isEmpty(reportsToDisplay)) { // Display Concierge chat report when there is no report to be displayed diff --git a/tests/unit/ReportUtilsTest.js b/tests/unit/ReportUtilsTest.js index e0b50ca54cca..c72162f82dbb 100644 --- a/tests/unit/ReportUtilsTest.js +++ b/tests/unit/ReportUtilsTest.js @@ -288,44 +288,15 @@ describe('ReportUtils', () => { it('returns false when there is no report', () => { expect(ReportUtils.isWaitingForIOUActionFromCurrentUser()).toBe(false); }); - it('returns false when there is no reports collection', () => { + it('returns false when the matched IOU report does not have an owner accountID', () => { const report = { ...LHNTestUtils.getFakeReport(), - iouReportID: '1', + ownerAccountID: undefined, + hasOutstandingIOU: true, }; expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false); }); - it('returns false when the report has no iouReportID', () => { - const report = LHNTestUtils.getFakeReport(); - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}2`, { - reportID: '2', - }).then(() => { - expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false); - }); - }); - it('returns false when there is no matching IOU report', () => { - const report = { - ...LHNTestUtils.getFakeReport(), - iouReportID: '1', - }; - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}2`, { - reportID: '2', - }).then(() => { - expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false); - }); - }); - it('returns false when the matched IOU report does not have an owner email', () => { - const report = { - ...LHNTestUtils.getFakeReport(), - iouReportID: '1', - }; - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}1`, { - reportID: '1', - }).then(() => { - expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false); - }); - }); - it('returns false when the matched IOU report does not have an owner email', () => { + it('returns false when the linked iou report has an oustanding IOU', () => { const report = { ...LHNTestUtils.getFakeReport(), iouReportID: '1', @@ -333,52 +304,37 @@ describe('ReportUtils', () => { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}1`, { reportID: '1', ownerAccountID: 99, + hasOutstandingIOU: true, }).then(() => { expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false); }); }); - it('returns true when the report has an oustanding IOU', () => { + it('returns true when the report has no oustanding IOU but is waiting for a bank account and the logged user is the report owner', () => { const report = { ...LHNTestUtils.getFakeReport(), - iouReportID: '1', - hasOutstandingIOU: true, + hasOutstandingIOU: false, + ownerAccountID: currentUserAccountID, + isWaitingOnBankAccount: true, }; - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}1`, { - reportID: '1', - ownerAccountID: 99, - hasOutstandingIOU: true, - }).then(() => { - expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(true); - }); + expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(true); }); - it('returns false when the report has no oustanding IOU', () => { + it('returns true when the report has no oustanding IOU but is waiting for a bank account and the logged user is not the report owner', () => { const report = { ...LHNTestUtils.getFakeReport(), - iouReportID: '1', hasOutstandingIOU: false, + ownerAccountID: 97, + isWaitingOnBankAccount: true, }; - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}1`, { - reportID: '1', - ownerAccountID: 99, - hasOutstandingIOU: false, - }).then(() => { - expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false); - }); + expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false); }); - it('returns true when the report has no oustanding IOU but is waiting for a bank account', () => { + it('returns true when the report has oustanding IOU', () => { const report = { ...LHNTestUtils.getFakeReport(), - iouReportID: '1', - hasOutstandingIOU: false, + ownerAccountID: 99, + hasOutstandingIOU: true, + isWaitingOnBankAccount: false, }; - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}1`, { - reportID: '1', - ownerAccountID: currentUserEmail, - hasOutstandingIOU: false, - isWaitingOnBankAccount: true, - }).then(() => { - expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false); - }); + expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(true); }); }); From 5a0a2699f0a510c02de2decb596cdae619c07a68 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Fri, 11 Aug 2023 12:34:59 -0700 Subject: [PATCH 11/36] Fix order tests --- tests/unit/SidebarOrderTest.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/SidebarOrderTest.js b/tests/unit/SidebarOrderTest.js index ffc619e7d578..51ff8fafdfa2 100644 --- a/tests/unit/SidebarOrderTest.js +++ b/tests/unit/SidebarOrderTest.js @@ -357,7 +357,7 @@ describe('Sidebar', () => { }; const report3 = { ...LHNTestUtils.getFakeReport([5, 6], 1), - hasOutstandingIOU: true, + hasOutstandingIOU: false, // This has to be added after the IOU report is generated iouReportID: null, @@ -403,8 +403,8 @@ describe('Sidebar', () => { expect(screen.queryAllByTestId('Pencil Icon')).toHaveLength(1); expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('One, Two'); expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Email Two owes $100.00'); - expect(lodashGet(displayNames, [2, 'props', 'children'])).toBe('Five, Six'); - expect(lodashGet(displayNames, [3, 'props', 'children'])).toBe('Three, Four'); + expect(lodashGet(displayNames, [2, 'props', 'children'])).toBe('Three, Four'); + expect(lodashGet(displayNames, [3, 'props', 'children'])).toBe('Five, Six'); }) ); }); From 169106b1edd52a7d1ac65ff1bd708e4a98b6ec6e Mon Sep 17 00:00:00 2001 From: situchan Date: Sun, 13 Aug 2023 21:49:01 +0600 Subject: [PATCH 12/36] disable iOS keyboard avoiding view on screens without text input --- src/pages/iou/MoneyRequestSelectorPage.js | 2 +- src/pages/iou/steps/NewRequestAmountPage.js | 1 + src/pages/settings/Security/TwoFactorAuth/CodesPage.js | 5 ++++- src/pages/tasks/NewTaskPage.js | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/MoneyRequestSelectorPage.js b/src/pages/iou/MoneyRequestSelectorPage.js index f1633d62e490..87597e8215e3 100644 --- a/src/pages/iou/MoneyRequestSelectorPage.js +++ b/src/pages/iou/MoneyRequestSelectorPage.js @@ -77,7 +77,7 @@ function MoneyRequestSelectorPage(props) { }; return ( - + {({safeAreaPaddingBottomStyle}) => ( diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index ce59840e106d..f17c18cab0a5 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -175,6 +175,7 @@ function NewRequestAmountPage({route, iou, report}) { return ( {({safeAreaPaddingBottomStyle}) => ( diff --git a/src/pages/settings/Security/TwoFactorAuth/CodesPage.js b/src/pages/settings/Security/TwoFactorAuth/CodesPage.js index 6780080ff382..29cefdc156a0 100644 --- a/src/pages/settings/Security/TwoFactorAuth/CodesPage.js +++ b/src/pages/settings/Security/TwoFactorAuth/CodesPage.js @@ -56,7 +56,10 @@ function CodesPage(props) { }, []); return ( - + + Task.dismissModalAndClearOutTaskInfo()} From d63c4cf08e169230ef37a7f27f1f8e4bd66b0960 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Wed, 9 Aug 2023 16:58:13 +0200 Subject: [PATCH 13/36] fix: replace new report with preexisting Signed-off-by: Yauheni Pasiukevich --- src/libs/Navigation/linkTo.js | 8 ++++++-- src/libs/actions/Report.js | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/linkTo.js b/src/libs/Navigation/linkTo.js index c610ae710992..8da7594cf6d4 100644 --- a/src/libs/Navigation/linkTo.js +++ b/src/libs/Navigation/linkTo.js @@ -60,8 +60,12 @@ export default function linkTo(navigation, path, type) { // If action type is different than NAVIGATE we can't change it to the PUSH safely if (action.type === 'NAVIGATE') { - // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH - if (action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && getTopmostReportId(root.getState()) !== getTopmostReportId(state)) { + // In case if type is 'FORCED_UP' we ensure that we need to replace current screen to the provided + if (type === 'FORCED_UP') { + action.type = 'REPLACE'; + + // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH + } else if (action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && getTopmostReportId(root.getState()) !== getTopmostReportId(state)) { action.type = 'PUSH'; // If the type is UP, we deeplinked into one of the RHP flows and we want to replace the current screen with the previous one in the flow diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index ec26c351de57..6ba578c6ba15 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -849,6 +849,20 @@ function handleReportChanged(report) { return; } + // It is possible that we optimistically created a DM/group-DM for a set of users for which a report already exists. + // In this case, the API will let us know by returning a preexistingReportID. + // We should clear out the optimistically created report and re-route the user to the preexisting report. + if (report && report.reportID && report.preexistingReportID) { + Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, null); + + // Only re-route them if they are still looking at the optimistically created report + if (Navigation.getActiveRoute().includes(`/r/${report.reportID}`)) { + // Pass 'FORCED_UP' type to replace new report on second login with proper one in the Navigation + Navigation.navigate(ROUTES.getReportRoute(report.preexistingReportID), 'FORCED_UP'); + } + return; + } + if (report && report.reportID) { allReports[report.reportID] = report; From b9155738ffaa1225588679f8cbf46921cd841967 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Thu, 10 Aug 2023 13:56:37 +0200 Subject: [PATCH 14/36] move navigate types to const Signed-off-by: Yauheni Pasiukevich --- src/CONST.js | 11 +++++++++++ src/libs/Navigation/Navigation.js | 3 ++- src/libs/Navigation/linkTo.js | 15 ++++++++------- src/libs/actions/Report.js | 4 ++-- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 4c19965837d9..0349888a6693 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -2534,6 +2534,17 @@ const CONST = { DISTANCE: 'distance', }, STATUS_TEXT_MAX_LENGTH: 100, + NAVIGATION: { + TYPE: { + FORCED_UP: 'FORCED_UP', + UP: 'UP', + }, + ACTION_TYPE: { + REPLACE: 'REPLACE', + PUSH: 'PUSH', + NAVIGATE: 'NAVIGATE', + }, + }, }; export default CONST; diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index 41f66967cc00..39f722c6b48a 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -12,6 +12,7 @@ import NAVIGATORS from '../../NAVIGATORS'; import originalGetTopmostReportId from './getTopmostReportId'; import getStateFromPath from './getStateFromPath'; import SCREENS from '../../SCREENS'; +import CONST from '../../CONST'; let resolveNavigationIsReadyPromise; const navigationIsReadyPromise = new Promise((resolve) => { @@ -127,7 +128,7 @@ function goBack(fallbackRoute = ROUTES.HOME, shouldEnforceFallback = false, shou } if (shouldEnforceFallback || (isFirstRouteInNavigator && fallbackRoute)) { - navigate(fallbackRoute, 'UP'); + navigate(fallbackRoute, CONST.NAVIGATION.TYPE.UP); return; } diff --git a/src/libs/Navigation/linkTo.js b/src/libs/Navigation/linkTo.js index 8da7594cf6d4..53d4ed381321 100644 --- a/src/libs/Navigation/linkTo.js +++ b/src/libs/Navigation/linkTo.js @@ -4,6 +4,7 @@ import NAVIGATORS from '../../NAVIGATORS'; import linkingConfig from './linkingConfig'; import getTopmostReportId from './getTopmostReportId'; import getStateFromPath from './getStateFromPath'; +import CONST from '../../CONST'; /** * Motivation for this function is described in NAVIGATION.md @@ -59,23 +60,23 @@ export default function linkTo(navigation, path, type) { const action = getActionFromState(state, linkingConfig.config); // If action type is different than NAVIGATE we can't change it to the PUSH safely - if (action.type === 'NAVIGATE') { + if (action.type === CONST.NAVIGATION.ACTION_TYPE.NAVIGATE) { // In case if type is 'FORCED_UP' we ensure that we need to replace current screen to the provided - if (type === 'FORCED_UP') { - action.type = 'REPLACE'; + if (type === CONST.NAVIGATION.TYPE.FORCED_UP) { + action.type = CONST.NAVIGATION.ACTION_TYPE.REPLACE; // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH } else if (action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && getTopmostReportId(root.getState()) !== getTopmostReportId(state)) { - action.type = 'PUSH'; + action.type = CONST.NAVIGATION.ACTION_TYPE.PUSH; // If the type is UP, we deeplinked into one of the RHP flows and we want to replace the current screen with the previous one in the flow // and at the same time we want the back button to go to the page we were before the deeplink - } else if (type === 'UP') { - action.type = 'REPLACE'; + } else if (type === CONST.NAVIGATION.TYPE.UP) { + action.type = CONST.NAVIGATION.ACTION_TYPE.REPLACE; // If this action is navigating to the RightModalNavigator and the last route on the root navigator is not RightModalNavigator then push } else if (action.payload.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && _.last(root.getState().routes).name !== NAVIGATORS.RIGHT_MODAL_NAVIGATOR) { - action.type = 'PUSH'; + action.type = CONST.NAVIGATION.ACTION_TYPE.PUSH; } } diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 6ba578c6ba15..c1d271945609 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -858,7 +858,7 @@ function handleReportChanged(report) { // Only re-route them if they are still looking at the optimistically created report if (Navigation.getActiveRoute().includes(`/r/${report.reportID}`)) { // Pass 'FORCED_UP' type to replace new report on second login with proper one in the Navigation - Navigation.navigate(ROUTES.getReportRoute(report.preexistingReportID), 'FORCED_UP'); + Navigation.navigate(ROUTES.getReportRoute(report.preexistingReportID), CONST.NAVIGATION.TYPE.FORCED_UP); } return; } @@ -1734,7 +1734,7 @@ function openReportFromDeepLink(url, isAuthenticated) { InteractionManager.runAfterInteractions(() => { SidebarUtils.isSidebarLoadedReady().then(() => { if (reportID) { - Navigation.navigate(ROUTES.getReportRoute(reportID), 'UP'); + Navigation.navigate(ROUTES.getReportRoute(reportID), CONST.NAVIGATION.TYPE.UP); } if (route === ROUTES.CONCIERGE) { navigateToConciergeChat(); From e95e540b84724a98e515c04ca75cc62e2f7f5093 Mon Sep 17 00:00:00 2001 From: VH Date: Mon, 14 Aug 2023 23:47:23 +0700 Subject: [PATCH 15/36] Hide reaction list when report message is deleted --- .../ReactionList/PopoverReactionList/index.js | 14 +++++++++++++- src/pages/home/report/ReportActionItem.js | 14 +++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/pages/home/report/ReactionList/PopoverReactionList/index.js b/src/pages/home/report/ReactionList/PopoverReactionList/index.js index c39eeddb7fd0..327885249843 100644 --- a/src/pages/home/report/ReactionList/PopoverReactionList/index.js +++ b/src/pages/home/report/ReactionList/PopoverReactionList/index.js @@ -29,7 +29,19 @@ function PopoverReactionList(props) { innerReactionListRef.current.showReactionList(event, reactionListAnchor); }; - useImperativeHandle(props.innerRef, () => ({showReactionList}), []); + const hideReactionList = () => { + innerReactionListRef.current.hideReactionList(); + }; + + /** + * Whether PopoverReactionList is active for the Report Action. + * + * @param {Number|String} actionID + * @return {Boolean} + */ + const isActiveReportAction = (actionID) => Boolean(actionID) && reactionListReportActionID === actionID; + + useImperativeHandle(props.innerRef, () => ({showReactionList, hideReactionList, isActiveReportAction})); return ( () => { - // ReportActionContextMenu and EmojiPicker are global component, - // we use showContextMenu and showEmojiPicker to show them, - // so we should also hide them when the current component is destroyed + // ReportActionContextMenu, EmojiPicker and PopoverReactionList are global components, + // we should also hide them when the current component is destroyed if (ReportActionContextMenu.isActiveReportAction(props.action.reportActionID)) { ReportActionContextMenu.hideContextMenu(); ReportActionContextMenu.hideDeleteModal(); @@ -141,8 +142,11 @@ function ReportActionItem(props) { if (EmojiPickerAction.isActiveReportAction(props.action.reportActionID)) { EmojiPickerAction.hideEmojiPicker(true); } + if (reactionListRef.current && reactionListRef.current.isActiveReportAction(props.action.reportActionID)) { + reactionListRef.current.hideReactionList(); + } }, - [props.action.reportActionID], + [props.action.reportActionID, reactionListRef], ); const isDraftEmpty = !props.draftMessage; From 98157f2327265a1e63c1cb378c06c0e22bece3ca Mon Sep 17 00:00:00 2001 From: situchan Date: Mon, 14 Aug 2023 23:36:05 +0600 Subject: [PATCH 16/36] fix lint --- src/pages/iou/MoneyRequestSelectorPage.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/MoneyRequestSelectorPage.js b/src/pages/iou/MoneyRequestSelectorPage.js index 87597e8215e3..4dd688950fbd 100644 --- a/src/pages/iou/MoneyRequestSelectorPage.js +++ b/src/pages/iou/MoneyRequestSelectorPage.js @@ -77,7 +77,10 @@ function MoneyRequestSelectorPage(props) { }; return ( - + {({safeAreaPaddingBottomStyle}) => ( From ea944e7db3f2efb2b5b7b68d86f40f0a8895334d Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Mon, 14 Aug 2023 10:49:48 -0700 Subject: [PATCH 17/36] Add comment --- src/libs/ReportUtils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index ac5ab7732e4e..f1b6b78830e9 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1148,6 +1148,7 @@ function isWaitingForIOUActionFromCurrentUser(report) { return true; } + // Money request waiting for current user to Pay (from expense or iou report) if (report.hasOutstandingIOU && report.ownerAccountID && (report.ownerAccountID !== currentUserAccountID || currentUserAccountID === report.managerID)) { return true; } From 43f38fb81d366fe083ce54b1000176112331f18e Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Mon, 14 Aug 2023 12:57:33 -0700 Subject: [PATCH 18/36] Fix tests --- tests/unit/SidebarOrderTest.js | 61 ++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/tests/unit/SidebarOrderTest.js b/tests/unit/SidebarOrderTest.js index 72b4a7e4818a..ef56fa8783b8 100644 --- a/tests/unit/SidebarOrderTest.js +++ b/tests/unit/SidebarOrderTest.js @@ -427,13 +427,12 @@ describe('Sidebar', () => { .then(() => { const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); - expect(displayNames).toHaveLength(4); + expect(displayNames).toHaveLength(3); expect(screen.queryAllByTestId('Pin Icon')).toHaveLength(1); expect(screen.queryAllByTestId('Pencil Icon')).toHaveLength(1); expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('One, Two'); expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Email Two owes $100.00'); expect(lodashGet(displayNames, [2, 'props', 'children'])).toBe('Three, Four'); - expect(lodashGet(displayNames, [3, 'props', 'children'])).toBe('Five, Six'); }) ); }); @@ -700,21 +699,31 @@ describe('Sidebar', () => { // Given three IOU reports containing the same IOU amounts const report1 = { ...LHNTestUtils.getFakeReport([1, 2]), - hasOutstandingIOU: true, // This has to be added after the IOU report is generated iouReportID: null, }; const report2 = { ...LHNTestUtils.getFakeReport([3, 4]), - hasOutstandingIOU: true, // This has to be added after the IOU report is generated iouReportID: null, }; const report3 = { ...LHNTestUtils.getFakeReport([5, 6]), - hasOutstandingIOU: true, + hasOutstandingIOU: false, + + // This has to be added after the IOU report is generated + iouReportID: null, + }; + const report4 = { + ...LHNTestUtils.getFakeReport([5, 6]), + + // This has to be added after the IOU report is generated + iouReportID: null, + }; + const report5 = { + ...LHNTestUtils.getFakeReport([5, 6]), // This has to be added after the IOU report is generated iouReportID: null, @@ -733,7 +742,7 @@ describe('Sidebar', () => { ...LHNTestUtils.getFakeReport([9, 10]), type: CONST.REPORT.TYPE.IOU, ownerAccountID: 2, - managerID: 2, + managerID: 3, hasOutstandingIOU: true, total: 10000, currency: 'USD', @@ -743,7 +752,27 @@ describe('Sidebar', () => { ...LHNTestUtils.getFakeReport([11, 12]), type: CONST.REPORT.TYPE.IOU, ownerAccountID: 2, - managerID: 2, + managerID: 4, + hasOutstandingIOU: true, + total: 100000, + currency: 'USD', + chatReportID: report3.reportID, + }; + const iouReport4 = { + ...LHNTestUtils.getFakeReport([11, 12]), + type: CONST.REPORT.TYPE.IOU, + ownerAccountID: 2, + managerID: 5, + hasOutstandingIOU: true, + total: 10000, + currency: 'USD', + chatReportID: report3.reportID, + }; + const iouReport5 = { + ...LHNTestUtils.getFakeReport([11, 12]), + type: CONST.REPORT.TYPE.IOU, + ownerAccountID: 2, + managerID: 6, hasOutstandingIOU: true, total: 10000, currency: 'USD', @@ -753,6 +782,8 @@ describe('Sidebar', () => { report1.iouReportID = iouReport1.reportID; report2.iouReportID = iouReport2.reportID; report3.iouReportID = iouReport3.reportID; + report4.iouReportID = iouReport4.reportID; + report5.iouReportID = iouReport5.reportID; const currentlyLoggedInUserAccountID = 13; LHNTestUtils.getDefaultRenderedSidebarLinks('0'); @@ -768,22 +799,26 @@ describe('Sidebar', () => { [`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1, [`${ONYXKEYS.COLLECTION.REPORT}${report2.reportID}`]: report2, [`${ONYXKEYS.COLLECTION.REPORT}${report3.reportID}`]: report3, + [`${ONYXKEYS.COLLECTION.REPORT}${report4.reportID}`]: report4, + [`${ONYXKEYS.COLLECTION.REPORT}${report5.reportID}`]: report5, [`${ONYXKEYS.COLLECTION.REPORT}${iouReport1.reportID}`]: iouReport1, [`${ONYXKEYS.COLLECTION.REPORT}${iouReport2.reportID}`]: iouReport2, [`${ONYXKEYS.COLLECTION.REPORT}${iouReport3.reportID}`]: iouReport3, + [`${ONYXKEYS.COLLECTION.REPORT}${iouReport4.reportID}`]: iouReport4, + [`${ONYXKEYS.COLLECTION.REPORT}${iouReport5.reportID}`]: iouReport5, }), ) - // Then the reports are ordered alphabetically since their amounts are the same + // Then the reports with the same amount are ordered alphabetically .then(() => { const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(5); - expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('Email Two owes $100.00'); - expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Email Two owes $100.00'); - expect(lodashGet(displayNames, [2, 'props', 'children'])).toBe('Email Two owes $100.00'); - expect(lodashGet(displayNames, [3, 'props', 'children'])).toBe('Five, Six'); - expect(lodashGet(displayNames, [4, 'props', 'children'])).toBe('One, Two'); + expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('Email Four owes $1,000.00'); + expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Email Five owes $100.00'); + expect(lodashGet(displayNames, [2, 'props', 'children'])).toBe('Email Six owes $100.00'); + expect(lodashGet(displayNames, [3, 'props', 'children'])).toBe('Email Three owes $100.00'); + expect(lodashGet(displayNames, [4, 'props', 'children'])).toBe('Email Two owes $100.00'); }) ); }); From 9245a7ddff4de29cc04e28e8e72860a59af72229 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 15 Aug 2023 11:23:50 +0800 Subject: [PATCH 19/36] ignore reveal button text from selection --- src/pages/home/report/ReportActionItem.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 3aa9113351c2..3ad10fba5aad 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -348,6 +348,7 @@ function ReportActionItem(props) { {isHidden ? props.translate('moderation.revealMessage') : props.translate('moderation.hideMessage')} From 96911d4bb9b5b09b6305cfd11471726ed7179beb Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 15 Aug 2023 16:00:46 +0700 Subject: [PATCH 20/36] fix: 24232 console log error when pressing ESC key --- src/setup/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/setup/index.js b/src/setup/index.js index 94aa27707012..d49baf25c0d7 100644 --- a/src/setup/index.js +++ b/src/setup/index.js @@ -35,6 +35,10 @@ export default function () { [ONYXKEYS.NETWORK]: {isOffline: false}, [ONYXKEYS.IS_SIDEBAR_LOADED]: false, [ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT]: true, + [ONYXKEYS.MODAL]: { + isVisible: false, + willAlertModalBecomeVisible: false, + }, }, }); From 5b5e039e3bc00bf1bc6795d2bf65b1669e6a5f7f Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 15 Aug 2023 21:54:50 +0700 Subject: [PATCH 21/36] Hide transaction detail when the request is deleted --- src/pages/home/report/ReportActionItem.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index d182dc4c6bc3..1fc124d3e937 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -463,7 +463,7 @@ function ReportActionItem(props) { if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { const parentReportAction = ReportActionsUtils.getParentReportAction(props.report); - if (ReportActionsUtils.isTransactionThread(parentReportAction)) { + if (ReportActionsUtils.isTransactionThread(parentReportAction) && !ReportActionsUtils.isDeletedParentAction(parentReportAction)) { return ( ); } + if (ReportActionsUtils.isTransactionThread(parentReportAction) && ReportActionsUtils.isDeletedParentAction(parentReportAction)) { + return null; + } if (ReportUtils.isTaskReport(props.report)) { return ( From 1be995b0205a3cb488db9627560b7d705301f96e Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 15 Aug 2023 23:06:32 +0700 Subject: [PATCH 22/36] Dismiss modal when the request is paid or deleted --- src/pages/EditRequestPage.js | 17 +++++++++++++++-- src/pages/home/report/ReportActionItem.js | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index 971ad056ae7e..ba9c089d8781 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useEffect} from 'react'; import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; import {withOnyx} from 'react-native-onyx'; @@ -38,7 +38,9 @@ const defaultProps = { }; function EditRequestPage({report, route}) { - const transactionID = lodashGet(ReportActionsUtils.getParentReportAction(report), 'originalMessage.IOUTransactionID', ''); + const parentReport = ReportUtils.getParentReport(report); + const parentReportAction = ReportActionsUtils.getParentReportAction(report); + const transactionID = lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', ''); const transaction = TransactionUtils.getTransaction(transactionID); const transactionDescription = TransactionUtils.getDescription(transaction); const transactionAmount = TransactionUtils.getAmount(transaction, ReportUtils.isExpenseReport(ReportUtils.getParentReport(report))); @@ -49,6 +51,17 @@ function EditRequestPage({report, route}) { const transactionCreated = format(transactionCreatedDate, CONST.DATE.FNS_FORMAT_STRING); const fieldToEdit = lodashGet(route, ['params', 'field'], ''); + const isDeleted = ReportActionsUtils.isDeletedAction(parentReportAction); + const isSetted = ReportUtils.isSettled(parentReport.reportID); + + // Dismiss the modal when the request is paid or deleted + useEffect(() => { + if (!isDeleted && !isSetted) { + return; + } + Navigation.dismissModal(); + }, [isDeleted, isSetted]); + // Update the transaction object and close the modal function editMoneyRequest(transactionChanges) { IOU.editMoneyRequest(transactionID, report.reportID, transactionChanges); diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 1fc124d3e937..b9d0367152b5 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -463,7 +463,7 @@ function ReportActionItem(props) { if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { const parentReportAction = ReportActionsUtils.getParentReportAction(props.report); - if (ReportActionsUtils.isTransactionThread(parentReportAction) && !ReportActionsUtils.isDeletedParentAction(parentReportAction)) { + if (ReportActionsUtils.isTransactionThread(parentReportAction) && !ReportActionsUtils.isDeletedAction(parentReportAction)) { return ( ); } - if (ReportActionsUtils.isTransactionThread(parentReportAction) && ReportActionsUtils.isDeletedParentAction(parentReportAction)) { + if (ReportActionsUtils.isTransactionThread(parentReportAction) && ReportActionsUtils.isDeletedAction(parentReportAction)) { return null; } if (ReportUtils.isTaskReport(props.report)) { From 9ad54237a009ce110f96afa8a7b1e338f3c280d5 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 15 Aug 2023 23:26:32 +0700 Subject: [PATCH 23/36] return null if request is deleted --- src/components/ReportActionItem/MoneyRequestView.js | 6 ++++++ src/pages/home/report/ReportActionItem.js | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 598fe8d096d9..91f035eb8e0b 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -83,6 +83,12 @@ function MoneyRequestView({report, parentReport, shouldShowHorizontalRule, polic description += ` • ${translate('iou.pending')}`; } + // A temporary solution to hide the transaction detail + // This will be removed after we probably add the transaction as a prop + if (ReportActionsUtils.isDeletedAction(parentReportAction)) { + return null; + } + return ( diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index b9d0367152b5..d182dc4c6bc3 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -463,7 +463,7 @@ function ReportActionItem(props) { if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { const parentReportAction = ReportActionsUtils.getParentReportAction(props.report); - if (ReportActionsUtils.isTransactionThread(parentReportAction) && !ReportActionsUtils.isDeletedAction(parentReportAction)) { + if (ReportActionsUtils.isTransactionThread(parentReportAction)) { return ( ); } - if (ReportActionsUtils.isTransactionThread(parentReportAction) && ReportActionsUtils.isDeletedAction(parentReportAction)) { - return null; - } if (ReportUtils.isTaskReport(props.report)) { return ( From c913c46ccd095dc8a4b847c9e90efabaf914ef45 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 15 Aug 2023 23:54:29 +0700 Subject: [PATCH 24/36] fix crash when deleting request --- src/libs/TransactionUtils.js | 6 +++--- src/pages/EditRequestPage.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/TransactionUtils.js b/src/libs/TransactionUtils.js index a05cd377514c..837a92443b8a 100644 --- a/src/libs/TransactionUtils.js +++ b/src/libs/TransactionUtils.js @@ -140,7 +140,7 @@ function getCurrency(transaction) { if (currency) { return currency; } - return lodashGet(transaction, 'currency', ''); + return lodashGet(transaction, 'currency', CONST.CURRENCY.USD); } /** @@ -150,11 +150,11 @@ function getCurrency(transaction) { * @returns {String} */ function getCreated(transaction) { - const created = lodashGet(transaction, 'modifiedCreated', ''); + const created = lodashGet(transaction, 'modifiedCreated', '') || lodashGet(transaction, 'created', ''); if (created) { return format(new Date(created), CONST.DATE.FNS_FORMAT_STRING); } - return format(new Date(lodashGet(transaction, 'created', '')), CONST.DATE.FNS_FORMAT_STRING); + return format(new Date(), CONST.DATE.FNS_FORMAT_STRING); } export {buildOptimisticTransaction, getUpdatedTransaction, getTransaction, getDescription, getAmount, getCurrency, getCreated}; diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index ba9c089d8781..b5eb2aee363a 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -43,7 +43,7 @@ function EditRequestPage({report, route}) { const transactionID = lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', ''); const transaction = TransactionUtils.getTransaction(transactionID); const transactionDescription = TransactionUtils.getDescription(transaction); - const transactionAmount = TransactionUtils.getAmount(transaction, ReportUtils.isExpenseReport(ReportUtils.getParentReport(report))); + const transactionAmount = TransactionUtils.getAmount(transaction, ReportUtils.isExpenseReport(parentReport)); const transactionCurrency = TransactionUtils.getCurrency(transaction); // Take only the YYYY-MM-DD value From 63ef1917e2e4168965f318405536ef3ffb2f931c Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 16 Aug 2023 00:06:08 +0700 Subject: [PATCH 25/36] subscribe parent report for dynamic update --- src/pages/EditRequestPage.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index b5eb2aee363a..cd288a55b520 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; import {withOnyx} from 'react-native-onyx'; import {format} from 'date-fns'; +import compose from '../libs/compose'; import CONST from '../CONST'; import Navigation from '../libs/Navigation/Navigation'; import ONYXKEYS from '../ONYXKEYS'; @@ -31,14 +32,17 @@ const propTypes = { /** The report object for the thread report */ report: reportPropTypes, + + /** The parent report object for the thread report */ + parentReport: reportPropTypes, }; const defaultProps = { report: {}, + parentReport: {}, }; -function EditRequestPage({report, route}) { - const parentReport = ReportUtils.getParentReport(report); +function EditRequestPage({report, route, parentReport}) { const parentReportAction = ReportActionsUtils.getParentReportAction(report); const transactionID = lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', ''); const transaction = TransactionUtils.getTransaction(transactionID); @@ -129,8 +133,15 @@ function EditRequestPage({report, route}) { EditRequestPage.displayName = 'EditRequestPage'; EditRequestPage.propTypes = propTypes; EditRequestPage.defaultProps = defaultProps; -export default withOnyx({ - report: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`, - }, -})(EditRequestPage); +export default compose( + withOnyx({ + report: { + key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`, + }, + }), + withOnyx({ + parentReport: { + key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`, + }, + }), +)(EditRequestPage); From 1c3126bec0700521e371be5258f9040a88b16cee Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Tue, 15 Aug 2023 10:52:32 -0700 Subject: [PATCH 26/36] add collection key --- .../xcshareddata/xcschemes/New Expensify.xcscheme | 10 +++++----- src/ONYXKEYS.js | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme index 23e118a2ba00..05e8fefc6dab 100644 --- a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme +++ b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme @@ -15,7 +15,7 @@ @@ -31,7 +31,7 @@ @@ -49,7 +49,7 @@ @@ -89,7 +89,7 @@ @@ -106,7 +106,7 @@ diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 64b3b960581f..836e47b2ccaf 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -118,6 +118,7 @@ export default { DOWNLOAD: 'download_', POLICY: 'policy_', POLICY_MEMBERS: 'policyMembers_', + POLICY_CATEGORIES: 'policyCategories_', WORKSPACE_INVITE_MEMBERS_DRAFT: 'workspaceInviteMembersDraft_', REPORT: 'report_', REPORT_ACTIONS: 'reportActions_', From b7be173a3424d65922219fe957974f86aed035d2 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Tue, 15 Aug 2023 10:55:53 -0700 Subject: [PATCH 27/36] remove unused --- .../xcshareddata/xcschemes/New Expensify.xcscheme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme index 05e8fefc6dab..23e118a2ba00 100644 --- a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme +++ b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme @@ -15,7 +15,7 @@ @@ -31,7 +31,7 @@ @@ -49,7 +49,7 @@ @@ -89,7 +89,7 @@ @@ -106,7 +106,7 @@ From b75325222e0d72cff4c058fa9a9051f1df5e003d Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 16 Aug 2023 01:00:36 +0700 Subject: [PATCH 28/36] fix crash in edit request page when deleting request money --- src/pages/EditRequestPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index cd288a55b520..7afd2d3f500d 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -141,7 +141,7 @@ export default compose( }), withOnyx({ parentReport: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report ? report.parentReportID : '0'}`, }, }), )(EditRequestPage); From 2f016d089df17f77d525628e8ba632e93fc5e15d Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 15 Aug 2023 13:26:09 -0600 Subject: [PATCH 29/36] Specify `output_name` in fastlane to match up with previous names --- fastlane/Fastfile | 1 + 1 file changed, 1 insertion(+) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 3eb22374f955..96a13c4d5cf9 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -203,6 +203,7 @@ platform :ios do build_app( workspace: "./ios/NewExpensify.xcworkspace", scheme: "New Expensify", + output_name: "New Expensify.ipa" export_options: { manageAppVersionAndBuildNumber: false } From 35fb0e53b51bf29776097a339a57029ee63a3c51 Mon Sep 17 00:00:00 2001 From: OSBotify Date: Tue, 15 Aug 2023 19:40:42 +0000 Subject: [PATCH 30/36] Update version to 1.3.54-10 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 56a987269f6e..81687960b221 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -90,8 +90,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001035409 - versionName "1.3.54-9" + versionCode 1001035410 + versionName "1.3.54-10" } flavorDimensions "default" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index 844086950b32..1c1f8a6db59e 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -32,7 +32,7 @@ CFBundleVersion - 1.3.54.9 + 1.3.54.10 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 2b3e076f1db8..90268774c421 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 1.3.54.9 + 1.3.54.10 diff --git a/package-lock.json b/package-lock.json index 7951d7dc2c8f..758d767f644f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.3.54-9", + "version": "1.3.54-10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.3.54-9", + "version": "1.3.54-10", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 1681ddfb597b..76e2c5103878 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.3.54-9", + "version": "1.3.54-10", "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.", From 6e4c31d56c357eea8f576bc77ce51713540b3d3d Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 15 Aug 2023 13:45:37 -0600 Subject: [PATCH 31/36] Add comma to new `output_name` key --- fastlane/Fastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 96a13c4d5cf9..92c61cb81b2c 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -203,7 +203,7 @@ platform :ios do build_app( workspace: "./ios/NewExpensify.xcworkspace", scheme: "New Expensify", - output_name: "New Expensify.ipa" + output_name: "New Expensify.ipa", export_options: { manageAppVersionAndBuildNumber: false } From d769b5cff5d537e3fe1b4d1b5d0329aa970e4e59 Mon Sep 17 00:00:00 2001 From: OSBotify Date: Tue, 15 Aug 2023 19:53:47 +0000 Subject: [PATCH 32/36] Update version to 1.3.54-11 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 81687960b221..d8d0c11a1a0c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -90,8 +90,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001035410 - versionName "1.3.54-10" + versionCode 1001035411 + versionName "1.3.54-11" } flavorDimensions "default" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index 1c1f8a6db59e..8817f8560fed 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -32,7 +32,7 @@ CFBundleVersion - 1.3.54.10 + 1.3.54.11 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 90268774c421..31dab672cd4e 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 1.3.54.10 + 1.3.54.11 diff --git a/package-lock.json b/package-lock.json index 758d767f644f..3e886a89af2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.3.54-10", + "version": "1.3.54-11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.3.54-10", + "version": "1.3.54-11", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 76e2c5103878..040b9a78896a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.3.54-10", + "version": "1.3.54-11", "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.", From de344083ed6f37e345db80f2f148a177045a5c09 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 16 Aug 2023 06:55:00 +0700 Subject: [PATCH 33/36] edit comment --- src/components/ReportActionItem/MoneyRequestView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 91f035eb8e0b..8502b0fb2fea 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -84,7 +84,7 @@ function MoneyRequestView({report, parentReport, shouldShowHorizontalRule, polic } // A temporary solution to hide the transaction detail - // This will be removed after we probably add the transaction as a prop + // This will be removed after we properly add the transaction as a prop if (ReportActionsUtils.isDeletedAction(parentReportAction)) { return null; } From d7821f593d037569b2de285446d9782919661493 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 16 Aug 2023 07:18:07 +0700 Subject: [PATCH 34/36] clear condition --- src/libs/TransactionUtils.js | 2 +- src/pages/EditRequestPage.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libs/TransactionUtils.js b/src/libs/TransactionUtils.js index 837a92443b8a..b424956cf4e0 100644 --- a/src/libs/TransactionUtils.js +++ b/src/libs/TransactionUtils.js @@ -154,7 +154,7 @@ function getCreated(transaction) { if (created) { return format(new Date(created), CONST.DATE.FNS_FORMAT_STRING); } - return format(new Date(), CONST.DATE.FNS_FORMAT_STRING); + return ''; } export {buildOptimisticTransaction, getUpdatedTransaction, getTransaction, getDescription, getAmount, getCurrency, getCreated}; diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index 7afd2d3f500d..071ffa0ccb40 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -2,7 +2,6 @@ import React, {useEffect} from 'react'; import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; import {withOnyx} from 'react-native-onyx'; -import {format} from 'date-fns'; import compose from '../libs/compose'; import CONST from '../CONST'; import Navigation from '../libs/Navigation/Navigation'; @@ -51,8 +50,7 @@ function EditRequestPage({report, route, parentReport}) { const transactionCurrency = TransactionUtils.getCurrency(transaction); // Take only the YYYY-MM-DD value - const transactionCreatedDate = new Date(TransactionUtils.getCreated(transaction)); - const transactionCreated = format(transactionCreatedDate, CONST.DATE.FNS_FORMAT_STRING); + const transactionCreated = TransactionUtils.getCreated(transaction); const fieldToEdit = lodashGet(route, ['params', 'field'], ''); const isDeleted = ReportActionsUtils.isDeletedAction(parentReportAction); From e2ed67bab1f1df933416907e2a846e72b225b3d2 Mon Sep 17 00:00:00 2001 From: Hans Date: Fri, 11 Aug 2023 16:40:31 +0700 Subject: [PATCH 35/36] make iou repliable add condition for split bill action makes iou repliable, sign commit. add condition for split bill action Update src/pages/home/report/ContextMenu/ContextMenuActions.js Co-authored-by: Situ Chandra Shil <108292595+situchan@users.noreply.github.com> optimize variable name update sign commit, var name and early return sign commit email --- src/libs/ReportActionsUtils.js | 9 +++++++++ .../home/report/ContextMenu/ContextMenuActions.js | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index 161dc540fca3..74f55d9b91b6 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -580,6 +580,14 @@ function isMessageDeleted(reportAction) { return lodashGet(reportAction, ['message', 0, 'isDeletedParentAction'], false); } +/** + * @param {*} reportAction + * @returns {Boolean} + */ +function isSplitBillAction(reportAction) { + return lodashGet(reportAction, 'originalMessage.type', '') === CONST.IOU.REPORT_ACTION_TYPE.SPLIT; +} + export { getSortedReportActions, getLastVisibleAction, @@ -614,4 +622,5 @@ export { isWhisperAction, isPendingRemove, getReportAction, + isSplitBillAction, }; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 79e49efb6a03..440cc46d6230 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -119,8 +119,15 @@ export default [ icon: Expensicons.ChatBubble, successTextTranslateKey: '', successIcon: null, - shouldShow: (type, reportAction, isArchivedRoom, betas, anchor, isChronosReport, reportID) => - type === CONTEXT_MENU_TYPES.REPORT_ACTION && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && !ReportUtils.isThreadFirstChat(reportAction, reportID), + shouldShow: (type, reportAction, isArchivedRoom, betas, anchor, isChronosReport, reportID) => { + if (type !== CONTEXT_MENU_TYPES.REPORT_ACTION) { + return false; + } + const isCommentAction = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && !ReportUtils.isThreadFirstChat(reportAction, reportID); + const isReportPreviewAction = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW; + const isIOUAction = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !ReportActionUtils.isSplitBillAction(reportAction); + return isCommentAction || isReportPreviewAction || isIOUAction; + }, onPress: (closePopover, {reportAction, reportID}) => { if (closePopover) { hideContextMenu(false, () => { From fc3c1aeb2bd73d089487cc434d9c613e42179ccb Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Wed, 16 Aug 2023 12:29:34 +0200 Subject: [PATCH 36/36] improve comments clearness Signed-off-by: Yauheni Pasiukevich --- src/libs/Navigation/linkTo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/linkTo.js b/src/libs/Navigation/linkTo.js index 53d4ed381321..884a8aa02190 100644 --- a/src/libs/Navigation/linkTo.js +++ b/src/libs/Navigation/linkTo.js @@ -61,11 +61,11 @@ export default function linkTo(navigation, path, type) { // If action type is different than NAVIGATE we can't change it to the PUSH safely if (action.type === CONST.NAVIGATION.ACTION_TYPE.NAVIGATE) { - // In case if type is 'FORCED_UP' we ensure that we need to replace current screen to the provided + // In case if type is 'FORCED_UP' we replace current screen with the provided. This means the current screen no longer exists in the stack if (type === CONST.NAVIGATION.TYPE.FORCED_UP) { action.type = CONST.NAVIGATION.ACTION_TYPE.REPLACE; - // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH + // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH the new screen to the top of the stack } else if (action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && getTopmostReportId(root.getState()) !== getTopmostReportId(state)) { action.type = CONST.NAVIGATION.ACTION_TYPE.PUSH;