Skip to content

Commit

Permalink
Merge pull request #33970 from Expensify/tgolen-refactor-reportscreen…
Browse files Browse the repository at this point in the history
…sideloading
  • Loading branch information
roryabraham authored Jan 10, 2024
2 parents 6aa9062 + 0cd7315 commit 8a559fd
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ const propTypes = {
/** The report metadata loading states */
reportMetadata: reportMetadataPropTypes,

/** Array of report actions for this report */
reportActions: PropTypes.arrayOf(PropTypes.shape(reportActionPropTypes)),
/** All the report actions for this report */
reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)),

/** The report's parentReportAction */
parentReportAction: PropTypes.shape(reportActionPropTypes),

/** Whether the composer is full size */
isComposerFullSize: PropTypes.bool,
Expand Down Expand Up @@ -105,7 +108,8 @@ const propTypes = {

const defaultProps = {
isSidebarLoaded: false,
reportActions: [],
reportActions: {},
parentReportAction: {},
report: {},
reportMetadata: {
isLoadingInitialReportActions: true,
Expand Down Expand Up @@ -145,6 +149,7 @@ function ReportScreen({
report,
reportMetadata,
reportActions,
parentReportAction,
accountManagerReportID,
personalDetails,
markReadyForHydration,
Expand Down Expand Up @@ -182,18 +187,11 @@ function ReportScreen({

// There are no reportActions at all to display and we are still in the process of loading the next set of actions.
const isLoadingInitialReportActions = _.isEmpty(reportActions) && reportMetadata.isLoadingInitialReportActions;

const isOptimisticDelete = lodashGet(report, 'statusNum') === CONST.REPORT.STATUS.CLOSED;

const shouldHideReport = !ReportUtils.canAccessReport(report, policies, betas);

const isLoading = !reportID || !isSidebarLoaded || _.isEmpty(personalDetails);

const parentReportAction = ReportActionsUtils.getParentReportAction(report);
const isSingleTransactionView = ReportUtils.isMoneyRequest(report);

const policy = policies[`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`] || {};

const isTopMostReportId = currentReportID === getReportID(route);
const didSubscribeToReportLeavingEvents = useRef(false);

Expand Down Expand Up @@ -236,7 +234,6 @@ function ReportScreen({
policy={policy}
personalDetails={personalDetails}
isSingleTransactionView={isSingleTransactionView}
parentReportAction={parentReportAction}
/>
);
}
Expand Down Expand Up @@ -609,6 +606,17 @@ export default compose(
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM}${getReportID(route)}`,
initialValue: false,
},
parentReportAction: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : 0}`,
selector: (parentReportActions, props) => {
const parentReportActionID = lodashGet(props, 'report.parentReportActionID');
if (!parentReportActionID) {
return {};
}
return parentReportActions[parentReportActionID];
},
canEvict: false,
},
},
true,
),
Expand Down

0 comments on commit 8a559fd

Please sign in to comment.