Skip to content

[HOLD for payment 2023-07-10] [$1000] Users are able to flag their own comment #21212

Closed

Description

@kbecciv

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Login with 2 account (A and B)
  2. Create a group chat between them, send some messages from account A.
  3. From account B, right click and choose Flag as offensive, copy the link and paste to the browser that account A is logging in.
  4. The Flag As Offensive page opened and you can flag your own comment.

Expected Result:

Users shouldn't be able to flag their own message

Actual Result:

Users are able to flag their own comment.

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.27-6

Reproducible in staging?: y

Reproducible in production?: y

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

Screen.Recording.2023-06-14.at.18.22.57.3.mov
Screen.Recording.2023-06-14.at.18.22.57.2.mov

Expensify/Expensify Issue URL:

Issue reported by: @hungvu193

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1686742370457539

Recording.802.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012f9f19f3eff4c785
  • Upwork Job ID: 1671569938552557568
  • Last Price Increase: 2023-06-21

Activity

  1. added
    Daily
    Bug
    on Jun 21, 2023
  2. melvin-bot commented on Jun 21, 2023

    @melvin-bot

    Triggered auto assignment to @abekkala (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  3. melvin-bot commented on Jun 21, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  4. kbecciv commented on Jun 21, 2023

    @kbecciv
    Author

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Users are able to flag their own comment.

    What is the root cause of that problem?

    We are not checking if current reportAction is your own comment inside FlagCommentPage.

    What changes do you think we should make in order to solve the problem?

    We should check if current reportAction is your own reportAction then we can decide the next step (it's depend on expected behavior). We can show not found view or set severityMenuItems to empty and leave a placeholder or dismiss the modal.

        const [shouldShowBlockingView, setShowBlockingView] = React.useState(false)
        React.useEffect(() => {
            let reportToCheck;
            // handle for thread
            if (reportAction === undefined) {
                reportToCheck = ReportActionsUtils.getParentReportAction(props.report);
            } else {
                reportToCheck = reportAction
            }
    
            if (props.session.email === reportToCheck.actorEmail) {
                setShowBlockingView(true); // or we can dismiss this modal
            }
        }, [reportAction, props.report]);
    
        if (shouldShowBlockingView) {
            return <NotFoundPage />
        }

    What alternative solutions did you explore? (Optional)

    N/A

  5. dukenv0307 commented on Jun 21, 2023

    @dukenv0307
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Users are able to flag their own comment

    What is the root cause of that problem?

    We don't prevent the user access to the page to flag their comment by URL flag/:reportID/:reportActionID

    What changes do you think we should make in order to solve the problem?

    In FlagCommentPage, We should use FullPageNotFoundView with conditions like here

    shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID) =>
    type === CONTEXT_MENU_TYPES.REPORT_ACTION &&
    ReportUtils.canFlagReportAction(reportAction, reportID) &&
    !isArchivedRoom &&
    !isChronosReport &&
    !ReportUtils.isConciergeChatReport(reportID) &&
    reportAction.actorEmail !== CONST.EMAIL.CONCIERGE,

    Also should use isLoadingReportData props from ONYX to check if the app is loading

    <ScreenWrapper includeSafeAreaPaddingBottom={false}>
                {({safeAreaPaddingBottomStyle}) => (
                    <FullPageNotFoundView shouldShow={
                           !isLoadingReportData && 
                           ReportUtils.canFlagReportAction(reportAction, reportID) &&
                           !isArchivedRoom &&
                           !isChronosReport &&
                           !ReportUtils.isConciergeChatReport(reportID) &&
                           reportAction.actorEmail !== CONST.EMAIL.CONCIERGE
                   }>
                        <HeaderWithBackButton title={props.translate('reportActionContextMenu.flagAsOffensive')} />
                        <ScrollView
                         ....
                    </FullPageNotFoundView>
                )}
            </ScreenWrapper>
    
    

    We also should move this code to outer of FlagComment Function to handle thread case

    if (reportAction === undefined) {
    reportID = ReportUtils.getParentReport(props.report).reportID;
    reportAction = ReportActionsUtils.getParentReportAction(props.report);
    }

    As this comment, In case, one account has 2 contact method (A and B), If we decide that A can't flag the comment of B we can update canEditReportAction function (because as I suggest above, we also use this function in FlagCommentPage)

    App/src/libs/ReportUtils.js

    Lines 201 to 210 in 5f5dd02

    function canEditReportAction(reportAction) {
    return (
    reportAction.actorEmail === sessionEmail &&
    reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT &&
    !isReportMessageAttachment(lodashGet(reportAction, ['message', 0], {})) &&
    !ReportActionsUtils.isDeletedAction(reportAction) &&
    !ReportActionsUtils.isCreatedTaskReportAction(reportAction) &&
    reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE
    );
    }

    We can use props.loginList instead of only sessionEmail to check

    Result

    Screenshot 2023-06-21 at 22 11 39
  6. added
    External
    on Jun 21, 2023
  7. changed the title [-]Users are able to flag their own comment[/-] [+][$1000] Users are able to flag their own comment[/+] on Jun 21, 2023
  8. melvin-bot commented on Jun 21, 2023

    @melvin-bot
  9. added
    Help Wanted
    on Jun 21, 2023
  10. melvin-bot commented on Jun 21, 2023

    @melvin-bot

    Current assignee @abekkala is eligible for the External assigner, not assigning anyone new.

  11. melvin-bot commented on Jun 21, 2023

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)

  12. ygshbht commented on Jun 21, 2023

    @ygshbht
    Contributor

    Proposal

    Hello Expensify Team,

    I'm Yogesh, a seasoned web developer with a robust track record on Upwork. My profile, which can be viewed here: https://www.upwork.com/freelancers/~01ca41cc1d47038084, showcases my 100% job success rate and a slew of positive reviews from satisfied clients. For a comprehensive look at the diverse projects I've contributed to, feel free to visit my portfolio at yogeshbhatt.com.

    On to the matter at hand: users being able to flag their own comments. My initial approach to resolve this would be to implement a backend check that verifies whether the commenter and the flagger are the same person. The outcome of this check could then be relayed to the frontend, where an appropriate error message could be displayed if necessary.

    However, it's important to note that the exact solution can only be ascertained after a thorough examination of your existing codebase and its architecture. As such, while the approach I've outlined seems plausible based on the information currently at hand, I would need to delve deeper into your code to confirm its viability and ensure its seamless integration with your current setup.

    As an experienced contributor, I've familiarized myself thoroughly with your Contributor Guidelines and README documentation. If granted the opportunity, I'm ready to uphold the highest standards of coding and conduct as part of your team.

    I look forward to the possibility of working together and helping to further enhance the user experience on your platform.

    Best regards,
    Yogesh

  13. 59 remaining items

  14. CortneyOfstad commented on Jul 18, 2023

    @CortneyOfstad
    Contributor

    @dukenv0307 sent the contract to you in UpWork — let me know as soon as you accept it and I can get that paid to you ASAP. Thanks for your patience, and sorry for the delay!

  15. dukenv0307 commented on Jul 18, 2023

    @dukenv0307
    Contributor

    @CortneyOfstad accepted, thank you!

  16. CortneyOfstad commented on Jul 18, 2023

    @CortneyOfstad
    Contributor

    Contract paid and completed! Closing!

  17. hungvu193 commented on Jul 18, 2023

    @hungvu193
    Contributor

    Contract paid and completed! Closing!

    @CortneyOfstad you forgot me 🥲

  18. CortneyOfstad commented on Jul 18, 2023

    @CortneyOfstad
    Contributor

    So I'm a bit confused. @mananjadhav can you provide some context?

  19. hungvu193 commented on Jul 18, 2023

    @hungvu193
    Contributor

    Ah I'm the reporter

  20. CortneyOfstad commented on Jul 18, 2023

    @CortneyOfstad
    Contributor

    OMG, I am so sorry! It's been a while since I've had to do this, so I'm a bit rusty! 😂

    Paying you now!! So sorry!!

  21. hungvu193 commented on Jul 18, 2023

    @hungvu193
    Contributor

    OMG, I am so sorry! It's been a while since I've had to do this, so I'm a bit rusty! 😂

    Paying you now!! So sorry!!

    No worries 🤣

  22. CortneyOfstad commented on Jul 18, 2023

    @CortneyOfstad
    Contributor

    All paid!

  23. mananjadhav commented on Jul 18, 2023

    @mananjadhav
    Collaborator

    Thanks @CortneyOfstad. Can we close this now?

  24. CortneyOfstad commented on Jul 18, 2023

    @CortneyOfstad
    Contributor

    Yep — closing now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions