Skip to content

Commit

Permalink
Merge pull request #33676 from Expensify/tgolen-clean-flagcommentpage
Browse files Browse the repository at this point in the history
Remove deprecated methods and refactor code to be a little cleaner
  • Loading branch information
luacmartins authored Jan 8, 2024
2 parents ab382e0 + 7669dc5 commit 1fe571e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pages/FlagCommentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as Report from '@userActions/Report';
import * as Session from '@userActions/Session';
Expand Down Expand Up @@ -43,10 +42,15 @@ const propTypes = {
}).isRequired,

...withLocalizePropTypes,

/* Onyx Props */
/** All the report actions from the parent report */
parentReportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)),
};

const defaultProps = {
reportActions: {},
parentReportActions: {},
report: {},
};

Expand Down Expand Up @@ -120,18 +124,19 @@ function FlagCommentPage(props) {

// Handle threads if needed
if (reportAction === undefined || reportAction.reportActionID === undefined) {
reportAction = ReportActionsUtils.getParentReportAction(props.report);
reportAction = props.parentReportActions[props.report.parentReportActionID] || {};
}

return reportAction;
}, [props.report, props.reportActions, props.route.params.reportActionID]);
}, [props.report, props.reportActions, props.route.params.reportActionID, props.parentReportActions]);

const flagComment = (severity) => {
let reportID = getReportID(props.route);
const reportAction = getActionToFlag();
const parentReportAction = props.parentReportActions[props.report.parentReportActionID] || {};

// Handle threads if needed
if (ReportUtils.isChatThread(props.report) && reportAction.reportActionID === ReportActionsUtils.getParentReportAction(props.report).reportActionID) {
if (ReportUtils.isChatThread(props.report) && reportAction.reportActionID === parentReportAction.reportActionID) {
reportID = ReportUtils.getParentReport(props.report).reportID;
}

Expand Down

0 comments on commit 1fe571e

Please sign in to comment.